# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
8377 |
2014-09-13T15:59:55 Z |
ainta |
On grid (kriii2_O) |
C++ |
|
0 ms |
2216 KB |
#include<stdio.h>
#include<algorithm>
using namespace std;
int D[2][310][310], n, m, S[310][310], pv, D2[2][310];
int main()
{
int i, j, k;
scanf("%d%d", &n,&m);
for (i = 1; i <= n; i++){
for (j = 1; j <= m; j++){
scanf("%d", &S[i][j]);
S[i][j] += S[i][j - 1];
}
}
for (i = 1; i <= m; i++){
D2[0][i] = D[0][i][i] = S[1][i];
}
for (i = 2; i <= n; i++){
for (j = 1; j <= m; j++)D2[!pv][j] = -1999999999;
for (j = 1; j <= m; j++){
for (k = 1; k <= j; k++){
D[!pv][j][k] = max(D[pv][j][k], D2[pv][j - k]) + S[i][j] - S[i][j - k];
D2[!pv][j] = max(D2[!pv][j], D[!pv][j][k]);
}
}
pv = !pv;
}
printf("%d\n", D2[pv][m]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2216 KB |
Output is correct |
2 |
Correct |
0 ms |
2216 KB |
Output is correct |
3 |
Incorrect |
0 ms |
2216 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |