#include<stdio.h>
#include<algorithm>
using namespace std;
int n, m, V[1000100], sum[1000100], dy[120000000];
inline int access(int i, int j){ return (m+1)*i+j;}
inline int access(int i, int ii, int j){ return (m+1)*((n+1)*i+ii)+j; }
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[access(i,j)]=-1;
}
else V[access(i,j)]=1;
sum[access(i,j)]=V[access(i,j)]+sum[access(i-1,j)];
}
}
for(i=0;i<n;++i){
for(ii=i+1;ii<=n;++ii){
for(j=1;j<=m;++j){
dy[access(i,ii,j)]=sum[access(ii,j)]-sum[access(i,j)]+min(dy[access(i,ii,j-1)],0);
wei=min(wei,dy[access(i,ii,j)]);
}
}
}
printf("%d\n",tot+wei);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
0 ms |
262144 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
0 ms |
262144 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
0 ms |
262144 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
0 ms |
262144 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
0 ms |
262144 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
0 ms |
262144 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |