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<algorithm>
using namespace std;
int n, m, V[160][2010], sum[160][2010], dy[160][160][2010];
int main(){
int i,ii,j,tmp,tot=0,wei=50000000;
scanf("%d %d",&n,&m);
for(i=1;i<=n;++i){
for(j=1;j<=m;++j){
scanf("%d",&tmp);
if(tmp){
++tot;
V[i][j]=-1;
}
else V[i][j]=1;
sum[i][j]=V[i][j]+sum[i-1][j];
}
}
for(i=0;i<n;++i){
for(ii=i+1;ii<=n;++ii){
for(j=1;j<=m;++j){
dy[i][ii][j]=sum[ii][j]-sum[i][j]+min(dy[i][ii][j-1],0);
wei=min(wei,dy[i][ii][j]);
}
}
}
printf("%d\n",tot+wei);
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... |