#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+10][m+10];
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 |
1728 KB |
Output is correct |
2 |
Correct |
2 ms |
1732 KB |
Output is correct |
3 |
Correct |
0 ms |
1732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
44056 KB |
Output is correct |
2 |
Correct |
121 ms |
44052 KB |
Output is correct |
3 |
Correct |
95 ms |
44056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
5772 KB |
Output is correct |
2 |
Correct |
19 ms |
5776 KB |
Output is correct |
3 |
Correct |
23 ms |
5772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1208 KB |
Output is correct |
2 |
Correct |
8 ms |
1208 KB |
Output is correct |
3 |
Correct |
9 ms |
1208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
250 ms |
4212 KB |
Output is correct |
2 |
Correct |
243 ms |
4220 KB |
Output is correct |
3 |
Correct |
241 ms |
4216 KB |
Output is correct |