Submission #18525

#TimeUsernameProblemLanguageResultExecution timeMemory
18525eaststarOrchard (NOI14_orchard)C++14
25 / 25
257 ms83120 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...