Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.087 s | 16 KBi |
#2 |
Correcto
|
0.107 s | 17 KBi |
#3 |
Correcto
|
0.095 s | 17 KBi |
#4 |
Correcto
|
0.09 s | 16 KBi |
#5 |
Correcto
|
0.111 s | 17 KBi |
#6 |
Correcto
|
0.085 s | 16 KBi |
#7 |
Correcto
|
0.086 s | 16 KBi |
#8 |
Incorrecto
|
0.126 s | 14 KBi |
#9 |
Incorrecto
|
0.1 s | 17 KBi |
#10 |
Incorrecto
|
0.087 s | 16 KBi |
#11 |
Correcto
|
0.086 s | 16 KBi |
#12 |
Correcto
|
0.086 s | 16 KBi |
#13 |
Incorrecto
|
0.083 s | 16 KBi |
#14 |
Correcto
|
0.093 s | 17 KBi |
#15 |
Correcto
|
0.092 s | 16 KBi |
#16 |
Correcto
|
0.252 s | 32 KBi |
#17 |
Correcto
|
0.261 s | 31 KBi |
#18 |
Correcto
|
0.285 s | 36 KBi |
#19 |
Correcto
|
0.236 s | 34 KBi |
#20 |
Incorrecto
|
0.328 s | 38 KBi |
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[][] matrix = new int[n][n]; int magicNumber = 0; boolean flag = true; for (int i = 0; i < n; i++) { int count = 0; for (int j = 0; j < n; j++) { matrix[i][j] = scanner.nextInt(); count += matrix[i][j]; } if (i == 0) { magicNumber = count; } else { if (magicNumber != count) { flag = false; } } } if (!flag) { System.out.println("No"); } int count1 = 0; int count2 = 0; for (int i = 0; i < n; i++) { int count = 0; for (int j = 0; j < n; j++) { count += matrix[j][i]; } if (magicNumber != count) { System.out.println("No"); return; } count1 += matrix[i][i]; count2 += matrix[i][(n-1)-i]; } if (magicNumber != count1 || magicNumber != count2) { System.out.println("No"); return; } System.out.println("Yes"); } }