Submission #18143

# Submission time Handle Problem Language Result Execution time Memory
18143 2016-01-24T14:24:01 Z tlwpdus On grid (kriii2_O) C++
0 / 4
0 ms 118580 KB
#include<stdio.h>
#include<algorithm>

using namespace std;

int r, c;
int map[310][310];
int dyn[310][310];
int psum[310][310];
int E[310][310][310];

void process() {
	int i, j, k;
	for (i=1;i<=r;i++) for (j=1;j<=c;j++) psum[i][j] = psum[i-1][j]+psum[i][j-1]-psum[i-1][j-1]+map[i][j];
	for (i=1;i<=r;i++) for (j=1;j<=c;j++) {
		for (k=1;k<i;k++) E[i][j][k] = max(E[i][j-1][k],dyn[k][j-1]+psum[k][j-1]-psum[i][j-1]);
		dyn[i][j] = psum[i][j];
		for (k=1;k<i;k++) dyn[i][j] = max(dyn[i][j],E[i][j][k]+psum[i][j]-psum[k][j]);
	}
	printf("%d\n",dyn[r][c]);
}

void input() {
	int i, j;
	scanf("%d %d",&r,&c);
	for (i=1;i<=r;i++) for (j=1;j<=c;j++) scanf("%d",&map[i][j]);
}

int main() {
	input();
	process();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 118580 KB Output is correct
2 Correct 0 ms 118580 KB Output is correct
3 Correct 0 ms 118580 KB Output is correct
4 Correct 0 ms 118580 KB Output is correct
5 Correct 0 ms 118580 KB Output is correct
6 Correct 0 ms 118580 KB Output is correct
7 Incorrect 0 ms 118580 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -