# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
8368 |
2014-09-13T14:43:53 Z |
cki86201 |
On grid (kriii2_O) |
C++ |
|
0 ms |
2520 KB |
#include<stdio.h>
#include<algorithm>
using namespace std;
//O(R^2 * C^2)
int d[303][303];
int p[303][303], b[303][303][2];
#define Get(a,b,c,d) (p[c][d]-p[a-1][d]-p[c][b-1]+p[a-1][b-1])
int main(){
int r,c,i,j;
scanf("%d%d",&r,&c);
for(i=1;i<=r;i++)for(j=1;j<=c;j++)scanf("%d",p[i]+j);
for(i=1;i<=r;i++)for(j=1;j<=c;j++)p[i][j] += p[i][j-1] + p[i-1][j] - p[i-1][j-1];
for(i=0;i<=r;i++)for(j=0;j<=c;j++)d[i][j] = (i||j) * (-1e9);
for(i=1;i<=r;i++)for(j=1;j<=c;j++){
int k, l;
for(k=max(1,b[i-1][j][0]);k<=i;k++)for(l=max(1,b[i][j-1][1]);l<=j;l++){
int t = d[k-1][l-1] + Get(k, l, i, j);
if(d[i][j] < t)d[i][j] = t, b[i][j][0] = k, b[i][j][1] = l;
}
}
printf("%d",d[r][c]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2520 KB |
Output is correct |
2 |
Correct |
0 ms |
2520 KB |
Output is correct |
3 |
Correct |
0 ms |
2520 KB |
Output is correct |
4 |
Incorrect |
0 ms |
2520 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |