Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.018 s | 1 KBi |
#9 |
Correcto
|
0.016 s | 1 KBi |
#10 |
Correcto
|
0.017 s | 1 KBi |
#11 |
Correcto
|
0.018 s | 1 KBi |
#12 |
Correcto
|
0.015 s | 1 KBi |
#13 |
Correcto
|
0.017 s | 1 KBi |
#14 |
Correcto
|
0.018 s | 7 KBi |
#15 |
Correcto
|
0.018 s | 1 KBi |
#16 |
Correcto
|
0.016 s | 1 KBi |
#17 |
Correcto
|
0.018 s | 1 KBi |
#18 |
Correcto
|
0.016 s | 1 KBi |
#include <iostream> #include <vector> #include <cassert> #include <algorithm> using namespace std; const int MAXN = 50; int a[MAXN][MAXN]; int main() { int rows, cols; cin >> rows >> cols; assert(1 <= rows and rows <= 50); assert(1 <= cols and cols <= 50); for (int i = 0; i < rows; ++i) { for (int j = 0; j < cols; ++j) { cin >> a[i][j]; } } int answer = a[0][0]; for (int r0 = 0; r0 < rows; ++r0) { vector<int> sum(cols, 0); for (int r1 = r0; r1 < rows; ++r1) { for (int c = 0; c < cols; ++c) { sum[c] += a[r1][c]; } for (int i = 0; i < cols; ++i) { int option = 0; for (int j = i; j < cols; ++j) { option += sum[j]; answer = max(answer, option); } } } } cout << answer << endl; return 0; }