Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 1 KBi |
#2 |
Correcto
|
0.004 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.004 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.003 s | 1 KBi |
#8 |
Correcto
|
0.024 s | 1 KBi |
#9 |
Correcto
|
0.031 s | 1 KBi |
#10 |
Correcto
|
0.033 s | 1 KBi |
#11 |
Correcto
|
0.034 s | 1 KBi |
#12 |
Correcto
|
0.028 s | 1 KBi |
#13 |
Correcto
|
0.022 s | 1 KBi |
#14 |
Correcto
|
0.022 s | 1 KBi |
#15 |
Correcto
|
0.028 s | 1 KBi |
#16 |
Correcto
|
0.021 s | 1 KBi |
#17 |
Correcto
|
0.033 s | 1 KBi |
#18 |
Correcto
|
0.02 s | 1 KBi |
#include <iostream> using namespace std; int main() { int R, C; cin >> R; cin >> C; int a[R][C]; int s[R][C]; for (int r = 0; r < R; r++) { for (int c = 0; c < C; c++) { cin >> a[r][c]; // calculate the summed-area table int sum = a[r][c]; if(r-1>=0) sum += s[r-1][c]; if(c-1>=0) sum += s[r][c-1]; if(c-1>=0 and r-1>=0) sum -= s[r-1][c-1]; s[r][c]= sum; } } int answer = s[0][0]; for (int r0 = 0; r0 < R; r0++) { for (int r1 = r0; r1 < R; r1++) { for (int c0 = 0; c0 < C; c0++) { for (int c1 = c0; c1 < C; c1++) { int sum = s[r1][c1]; if(r0>0) sum -= s[r0-1][c1]; if(c0>0) sum -= s[r1][c0-1]; if(c0>0 and r0 > 0) sum += s[r0-1][c0-1]; answer = max(sum, answer); } } } } cout << answer << endl; return 0; }