Rezultati

Up. imeNalogaJezikRezultatČas oddaje
scnm1-2018 Kvadrat števil Java 100/100OK 13. okt '18 @ 11:09

Test Točke Porabljen spomin Porabljen čas Status
#1 10/10 34,012 MiB 0,000 s OK
#2 10/10 36,938 MiB 0,000 s OK
#3 10/10 35,602 MiB 0,000 s OK
#4 10/10 33,406 MiB 0,000 s OK
#5 10/10 42,430 MiB 0,000 s OK
#6 10/10 42,578 MiB 0,000 s OK
#7 10/10 48,422 MiB 0,132 s OK
#8 10/10 48,039 MiB 0,294 s OK
#9 10/10 49,035 MiB 0,062 s OK
#10 10/10 47,402 MiB 0,207 s OK

Ocenjevani program (n1.java):
import java.util.*;
import java.io.*;

public class n1 {
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		int[][]q=new int[n][n];
		int[]num=new int[n*n];
		for(int i=0;i<n*n;i++) {
			num[i]=Integer.parseInt(in.readLine());
		}
		Arrays.sort(num);
		int pmid=n/2;
		int p=num.length-1;
		for(int dist=0;dist<n;dist++) {
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) {
					if(Math.abs(pmid-i)+Math.abs(pmid-j)==dist) {
						q[i][j]=num[p--];
					}
				}
			}
		}
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				System.out.print(q[i][j]+" ");
			}
			System.out.println();
		}
	}
}