#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 |
1 |
Correct |
0 ms |
204596 KB |
Output is correct |
2 |
Correct |
0 ms |
204596 KB |
Output is correct |
3 |
Correct |
0 ms |
204596 KB |
Output is correct |
4 |
Correct |
0 ms |
204596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204596 KB |
Output is correct |
2 |
Correct |
0 ms |
204596 KB |
Output is correct |
3 |
Correct |
2 ms |
204596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
204596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
204596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
204596 KB |
Output is correct |
2 |
Correct |
8 ms |
204596 KB |
Output is correct |
3 |
Correct |
12 ms |
204596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
303 ms |
204596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |