Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.151 s | 16 KBi |
#2 |
Incorrecto
|
0.14 s | 15 KBi |
#3 |
Incorrecto
|
0.157 s | 15 KBi |
#4 |
Incorrecto
|
0.167 s | 12 KBi |
#5 |
Incorrecto
|
0.154 s | 15 KBi |
#6 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.167 s | 15 KBi |
#7 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.156 s | 15 KBi |
#8 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.146 s | 15 KBi |
#9 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.162 s | 15 KBi |
#10 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.164 s | 15 KBi |
#11 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.135 s | 15 KBi |
#12 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.127 s | 15 KBi |
#13 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.139 s | 15 KBi |
#14 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.137 s | 16 KBi |
#15 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.144 s | 16 KBi |
#16 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.177 s | 12 KBi |
#17 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.15 s | 15 KBi |
#18 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.NegativeArraySizeException: -1 at Main.main(Main.java:15) |
0.171 s | 12 KBi |
import java.util.Scanner; public class Main { public static void main(String[] args) { //input String dimensiones= leer.nextLine().trim(); int filas=Character.getNumericValue(dimensiones.charAt(0)); int columnas=Character.getNumericValue(dimensiones.charAt(2)); int[][] ejemplo1= new int[filas][columnas]; for (int i = 0; i < filas; i++) { String filaDada= leer.nextLine().trim(); int k=0; for (int j = 0; j < columnas; j++) { if(filaDada.charAt(k)=='-'){ ejemplo1[i][j]=-1*Character.getNumericValue(filaDada.charAt(k+1)); k++; }else{ ejemplo1[i][j]=Character.getNumericValue(filaDada.charAt(k)); } k+=2; System.out.println(ejemplo1[i][j]); } } int toret = valorSubmatrizMaxima(ejemplo1, filas, columnas); System.out.println(toret); } public static Scanner leer = new Scanner(System.in); public static int valorSubmatrizMaxima(int[][] matriz, int filas, int columnas) { //crear matriz con suma de columnas acumulada int[][] matrizSumaColumnas = new int[filas][columnas]; for (int i = 0; i < columnas; i++) { for (int j = 0; j < filas; j++) { if (j == 0) { matrizSumaColumnas[j][i] = matriz[j][i]; } else { matrizSumaColumnas[j][i] = matriz[j][i] + matrizSumaColumnas[j - 1][i]; } } } //algoritmo como el que teniamos en la busqueda del subarray maximo int maximoLocal = Integer.MIN_VALUE;; int minimo, subMatriz; for (int i = 0; i < filas; i++) { for (int j = i; j < filas; j++) { minimo = 0; subMatriz = 0; for (int k = 0; k < columnas; k++) { if (i == 0) { subMatriz += matrizSumaColumnas[j][k]; } else { subMatriz += matrizSumaColumnas[j][k] - matrizSumaColumnas[i - 1][k]; } if (subMatriz < minimo) { minimo = subMatriz; } if ((subMatriz - minimo) > maximoLocal) { maximoLocal = subMatriz - minimo; } } } } return maximoLocal; } }