#include<stdio.h>
#define min(a,b) (a<b?a:b)
int n, m, sum[1000100], dy[1000100];
inline int access(int i, int j){ return (m+1)*i+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;
sum[access(i,j)]=sum[access(i-1,j)]-1;
}
else sum[access(i,j)]=sum[access(i-1,j)]+1;
}
}
for(i=0;i<n;++i){
for(ii=i+1;ii<=n;++ii){
for(j=1;j<=m;++j){
dy[j]=sum[access(ii,j)]-sum[access(i,j)]+min(dy[j-1],0);
wei=min(wei,dy[j]);
}
}
}
printf("%d\n",tot+wei);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
8896 KB |
Output is correct |
2 |
Correct |
0 ms |
8896 KB |
Output is correct |
3 |
Correct |
0 ms |
8896 KB |
Output is correct |
4 |
Correct |
0 ms |
8896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8896 KB |
Output is correct |
2 |
Correct |
0 ms |
8896 KB |
Output is correct |
3 |
Correct |
0 ms |
8896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
8896 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
8896 KB |
Output is correct |
2 |
Correct |
20 ms |
8896 KB |
Output is correct |
3 |
Correct |
21 ms |
8896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8896 KB |
Output is correct |
2 |
Correct |
10 ms |
8896 KB |
Output is correct |
3 |
Correct |
10 ms |
8896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
305 ms |
8896 KB |
Output is correct |
2 |
Correct |
325 ms |
8896 KB |
Output is correct |
3 |
Correct |
287 ms |
8896 KB |
Output is correct |