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>
#include <string.h>
int main(){
int i,j,k,l,n,m,ans=1e6,mn,t;
scanf("%d%d",&n,&m);
int a[n+20][m+20];
memset(a,0,sizeof a);
for(i=1;i<=n;++i){
for(j=1;j<=m;++j)scanf("%d",a[i]+j),a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
}
for(i=1;i<=n;++i){
for(j=i;j<=n;++j){
mn=1e6;
for(k=1;k<=m;++k){
t=2*(a[j][k-1]-a[i-1][k-1])-(j-i+1)*k;
if(mn>t)mn=t;
t=a[n][m]+(j-i+1)*(k+1)-2*(a[j][k]-a[i-1][k])+mn;
if(ans>t)ans=t;
}
}
}
printf("%d",ans);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |