Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.146 s | 17 KBi |
#2 |
Correcto
|
0.131 s | 13 KBi |
#3 |
Correcto
|
0.148 s | 15 KBi |
#4 |
Correcto
|
0.173 s | 20 KBi |
#5 |
Correcto
|
0.122 s | 12 KBi |
#6 |
Correcto
|
0.225 s | 13 KBi |
#7 |
Correcto
|
0.131 s | 32 KBi |
#8 |
Correcto
|
0.24 s | 18 KBi |
#9 |
Correcto
|
0.178 s | 15 KBi |
#10 |
Correcto
|
0.127 s | 13 KBi |
#11 |
Correcto
|
0.175 s | 23 KBi |
#12 |
Correcto
|
0.135 s | 29 KBi |
#13 |
Correcto
|
0.136 s | 13 KBi |
#14 |
Correcto
|
0.28 s | 15 KBi |
#15 |
Correcto
|
0.123 s | 53 KBi |
#16 |
Correcto
|
0.318 s | 18 KBi |
#17 |
Correcto
|
0.199 s | 16 KBi |
#18 |
Correcto
|
0.214 s | 39 KBi |
#19 |
Correcto
|
0.242 s | 18 KBi |
#20 |
Correcto
|
0.364 s | 15 KBi |
import java.util.*; public class Main { public static void main(String args[]){ ArrayList<Integer> result = new ArrayList<Integer>(); Scanner inputData = new Scanner(System.in); String returnValue=""; String numRowsColumns = inputData.nextLine(); String elements; String matriz[][] = new String[Integer.parseInt(numRowsColumns)][Integer.parseInt(numRowsColumns)]; for(int i=0;i < Integer.parseInt(numRowsColumns);i++) { elements=""; elements+= inputData.nextLine(); fillmatrix(matriz,elements,i); } int sum1=0; int sum2=0; int sum3; int sum4; for(int k=0; k < Integer.parseInt(numRowsColumns); k++) { sum3=0; sum4=0; for(int p=0; p < Integer.parseInt(numRowsColumns); p++) { sum3+=Integer.parseInt(matriz[k][p]); sum4+=Integer.parseInt(matriz[p][k]); if(k==p) { sum1+= Integer.parseInt(matriz[k][p]); } if((Integer.parseInt(numRowsColumns)-(k+1)) ==p) { sum2+= Integer.parseInt(matriz[k][p]); } } result.add(sum3); result.add(sum4); } result.add(sum1); result.add(sum2); returnValue=printData(result); System.out.println(returnValue); } public static void fillmatrix(String[][] matrix,String c, int row) { String[] valores = c.split(" "); for(int i =0; i < valores.length; i++) { matrix[row][i]=valores[i]; } } public static String printData(ArrayList<Integer> data) { String result="Yes"; Integer firstValue = data.get(1); for(Integer value: data) { if(!firstValue.equals(value)) { result="No"; break; } } return result; } }