Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 0 KBi |
#2 |
Correcto
|
0.003 s | 0 KBi |
#3 |
Correcto
|
0.004 s | 0 KBi |
#4 |
Correcto
|
0.005 s | 0 KBi |
#5 |
Correcto
|
0.004 s | 0 KBi |
#6 |
Correcto
|
0.004 s | 2 KBi |
#7 |
Correcto
|
0.005 s | 0 KBi |
#8 |
Correcto
|
0.022 s | 7 KBi |
#9 |
Correcto
|
0.018 s | 0 KBi |
#10 |
Correcto
|
0.027 s | 0 KBi |
#11 |
Correcto
|
0.015 s | 0 KBi |
#12 |
Correcto
|
0.022 s | 8 KBi |
#13 |
Correcto
|
0.024 s | 0 KBi |
#14 |
Correcto
|
0.022 s | 0 KBi |
#15 |
Correcto
|
0.02 s | 5 KBi |
#16 |
Correcto
|
0.018 s | 3 KBi |
#17 |
Correcto
|
0.027 s | 0 KBi |
#18 |
Correcto
|
0.015 s | 10 KBi |
#include <iostream> using namespace std; int main() { int R, C; cin >> R >> C; int matrix[R][C]; for (int i = 0; i < R; i++) { for (int j = 0; j < C; j++) { cin >> matrix[i][j]; if (i >= 1) matrix[i][j] += matrix[i-1][j]; if (j >= 1) matrix[i][j] += matrix[i][j-1]; if (i >= 1 && j >= 1) matrix[i][j] -= matrix[i-1][j-1]; } } int max = matrix[0][0]; for (int r0 = 0; r0 < R; r0++) { for (int c0 = 0; c0 < C; c0++) { for (int r1 = r0; r1 < R; r1++) { for (int c1 = c0; c1 < C; c1++) { int sum = matrix[r1][c1]; if (r0 >= 1) sum -= matrix[r0-1][c1]; if (c0 >= 1) sum -= matrix[r1][c0 -1]; if (r0 >= 1 && c0 >= 1) sum += matrix[r0-1][c0-1]; if (sum > max) max = sum; } } } } cout << max << endl; return 0; }