Submission #9185

# Submission time Handle Problem Language Result Execution time Memory
9185 2014-09-28T04:27:17 Z myungwoo On grid (kriii2_O) C++14
0 / 4
0 ms 2504 KB
#include <stdio.h>

int N, M;
int A[301][301], S[301][301], D[301][301], V[301][301];

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", A[i]+j), S[i][j] = A[i][j]+S[i-1][j]+S[i][j-1]-S[i-1][j-1];
	for (i=0;i<=N;i++) for (j=0;j<=N;j++) V[i][j] = -2e9;
	for (j=1;j<=M;j++) for (i=1;i<=N;i++){
		D[i][j] = S[i][j];
		for (int a=0;a<i;a++){
			if (D[i][j] < V[a][i]+S[i][j]-S[a][j])
				D[i][j] = V[a][i]+S[i][j]-S[a][j];
		}
		for (int a=i+1;a<=N;a++){
			if (V[i][a] < D[i][j]-S[a][j]+S[i][j])
				V[i][a] = D[i][j]-S[a][j]+S[i][j];
		}
	}
	printf("%d\n", D[N][M]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2504 KB Output is correct
2 Correct 0 ms 2504 KB Output is correct
3 Correct 0 ms 2504 KB Output is correct
4 Incorrect 0 ms 2504 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -