Submission #9205

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
92052014-09-28 04:39:08myungwooOn grid (kriii2_O)C++14
4 / 4
92 ms2504 KiB
#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]);
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...