# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
8376 |
2014-09-13T15:58:13 Z |
cki86201 |
On grid (kriii2_O) |
C++ |
|
0 ms |
3240 KB |
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
//O(R^2 * C)
int d[303][303];
int p[303][303];
int b[2][303][606], t;
#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=1;i<=r;i++)for(j=1;j<=c;j++)d[i][j] = p[i][j];
for(i=2;i<=r;i++){
for(j=i-1;j;j--){
int t = 1, now = 0, mx;
d[i][2] = max(d[i][2], mx = d[j][1] + Get(j+1,2,i,2));
for(int k=3;k<=c;k++){
mx += Get(j+1,k,i,k);
now += Get(1,k-1,j,k-1) - Get(j+1,k-1,i,k-1);
if(now > 0)mx += now, now = 0;
d[i][k] = max(d[i][k], mx);
}
}
}
printf("%d",d[r][c]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
3240 KB |
Output is correct |
2 |
Incorrect |
0 ms |
3240 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Halted |
0 ms |
0 KB |
- |