Rezultati

Up. imeNalogaJezikRezultatČas oddaje
lml-2018 Tabela Java 0/100Prekoračen čas (TLE) 13. okt '18 @ 10:57

Test Točke Porabljen spomin Porabljen čas Status
#1 0/20 68,309 MiB 0,000 s Prekoračen čas
#2 20/20 39,863 MiB 0,000 s OK
#3 20/20 39,094 MiB 0,000 s OK
#4 20/20 38,934 MiB 0,000 s OK
#5 20/20 37,703 MiB 0,000 s OK

Ocenjevani program (Tabela.java):
import java.util.*;

public class Tabela
{
    public static void main(String[]args)
    {
        Scanner skan = new Scanner(System.in);
        String bla = skan.nextLine();
        String[] blabla = bla.split(" ");
        int h = Integer.parseInt(blabla[0]);
        int w = Integer.parseInt(blabla[1]);
        String[][] tabela = new String[h][w];
        String poravnava = skan.nextLine();
        int[] largest = new int[w];

        for(int i = 0; i < h; i++)
        {
            String vhod = skan.nextLine();
            String[] v = vhod.split(",");

            for(int j = 0; j < w; j++)
            {
                tabela[i][j] = v[j];

                if(v[j].length() > largest[j])
                {
                    largest[j] = v[j].length();
                }
            } 
        }

        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                if(poravnava.charAt(j) == 'L')
                {
                    System.out.print(tabela[i][j]);
                    int end = largest[j] - tabela[i][j].length();

                    for(int k = 0; k < end; k++)
                    {
                        System.out.print(" ");
                    }

                    if(j == w - 1)
                    {
                        System.out.println();
                    }
                    else
                    {
                        System.out.print(" | ");
                    }
                }
                else
                {
                    int end = largest[j] - tabela[i][j].length();

                    for(int k = 0; k < end; k++)
                    {
                        System.out.print(" ");
                    }

                    System.out.print(tabela[i][j]);

                    if(j == w - 1)
                    {
                        System.out.println();
                    }
                    else
                    {
                        System.out.print(" | ");
                    }
                }
            }
        }
    }
}