#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+1][m+1];
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 time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1208 KB |
Output is correct |
2 |
Correct |
2 ms |
1208 KB |
Output is correct |
3 |
Correct |
0 ms |
1208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
8900 KB |
Output is correct |
2 |
Correct |
109 ms |
8892 KB |
Output is correct |
3 |
Correct |
104 ms |
8896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
2256 KB |
Output is correct |
2 |
Correct |
24 ms |
2256 KB |
Output is correct |
3 |
Correct |
28 ms |
2252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
256 ms |
4032 KB |
Output is correct |
2 |
Correct |
239 ms |
4036 KB |
Output is correct |
3 |
Correct |
252 ms |
4032 KB |
Output is correct |