이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |