Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.087 s | 16 KBi |
#2 |
Correcto
|
0.135 s | 13 KBi |
#3 |
Correcto
|
0.09 s | 16 KBi |
#4 |
Correcto
|
0.092 s | 16 KBi |
#5 |
Correcto
|
0.076 s | 16 KBi |
#6 |
Correcto
|
0.086 s | 16 KBi |
#7 |
Correcto
|
0.101 s | 17 KBi |
#8 |
Incorrecto
|
0.11 s | 17 KBi |
#9 |
Incorrecto
|
0.084 s | 16 KBi |
#10 |
Incorrecto
|
0.078 s | 16 KBi |
#11 |
Correcto
|
0.143 s | 14 KBi |
#12 |
Correcto
|
0.107 s | 17 KBi |
#13 |
Incorrecto
|
0.077 s | 16 KBi |
#14 |
Correcto
|
0.119 s | 17 KBi |
#15 |
Correcto
|
0.1 s | 16 KBi |
#16 |
Correcto
|
0.26 s | 32 KBi |
#17 |
Correcto
|
0.286 s | 37 KBi |
#18 |
Correcto
|
0.23 s | 34 KBi |
#19 |
Correcto
|
0.289 s | 33 KBi |
#20 |
Incorrecto
|
0.264 s | 31 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[i][j]; } 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"); } }