# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9205 | myungwoo | On grid (kriii2_O) | C++14 | 92 ms | 2504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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] = -1e9;
for (j=1;j<=M;j++) for (i=N;i;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 |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |