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>
#define M 305
int t[M][M],sum[M][M],a[M][M];
int main()
{
int i,j,k,w,n,m;
scanf("%d %d",&n,&m);
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
scanf("%d",&a[i][j]);
sum[i][j]+=sum[i][j-1]+a[i][j];
t[i][j]=sum[i][j];
}
for(j=1;j<=m;j++){
sum[i][j]+=sum[i-1][j];
}
}
for(i=2;i<=n;i++){
for(j=2;j<=m;j++){
for(k=1;k<i;k++){
for(w=1;w<i;w++){
if(t[i][j]<t[k][w]+(sum[i][j]-sum[k][j]-sum[i][w]+sum[k][w])){
t[i][j]=t[k][w]+(sum[i][j]-sum[k][j]-sum[i][w]+sum[k][w]);
}
}
}
}
}
printf("%d\n",t[n][m]);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |