Submission #8367

# Submission time Handle Problem Language Result Execution time Memory
8367 2014-09-13T14:30:24 Z cki86201 On grid (kriii2_O) C++
1 / 4
1000 ms 1804 KB
#include<stdio.h>
#include<algorithm>

//O(R^2 * C^2)
int d[303][303];
int p[303][303];
#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=i;k;k--)for(l=j;l;l--)
			d[i][j] = std::max(d[i][j], d[k-1][l-1] + Get(k, l, i, j));
	}
	printf("%d",d[r][c]);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1804 KB Output is correct
2 Correct 0 ms 1804 KB Output is correct
3 Correct 0 ms 1804 KB Output is correct
4 Correct 0 ms 1804 KB Output is correct
5 Correct 0 ms 1804 KB Output is correct
6 Correct 0 ms 1804 KB Output is correct
7 Correct 0 ms 1804 KB Output is correct
8 Correct 0 ms 1804 KB Output is correct
9 Correct 0 ms 1804 KB Output is correct
10 Correct 0 ms 1804 KB Output is correct
11 Correct 0 ms 1804 KB Output is correct
12 Correct 0 ms 1804 KB Output is correct
13 Correct 0 ms 1804 KB Output is correct
14 Correct 0 ms 1804 KB Output is correct
15 Correct 0 ms 1804 KB Output is correct
16 Correct 0 ms 1804 KB Output is correct
17 Correct 0 ms 1804 KB Output is correct
18 Correct 0 ms 1804 KB Output is correct
19 Correct 0 ms 1804 KB Output is correct
20 Correct 0 ms 1804 KB Output is correct
21 Correct 0 ms 1804 KB Output is correct
22 Correct 0 ms 1804 KB Output is correct
23 Correct 0 ms 1804 KB Output is correct
24 Correct 0 ms 1804 KB Output is correct
25 Correct 0 ms 1804 KB Output is correct
26 Correct 0 ms 1804 KB Output is correct
27 Correct 0 ms 1804 KB Output is correct
28 Correct 0 ms 1804 KB Output is correct
29 Correct 0 ms 1804 KB Output is correct
30 Correct 0 ms 1804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 440 ms 1804 KB Output is correct
2 Correct 164 ms 1804 KB Output is correct
3 Correct 704 ms 1804 KB Output is correct
4 Correct 392 ms 1804 KB Output is correct
5 Correct 184 ms 1804 KB Output is correct
6 Execution timed out 1000 ms 1804 KB Program timed out
7 Halted 0 ms 0 KB -