This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, m, o = 0;
cin >> n >> m;
int a[n + 1][m + 1], pref[m + 1];
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> a[i][j];
if(a[i][j]) o++;
else a[i][j] = -1;
}
}
int ans = INT_MIN;
for(int i = 1; i < n + 1; i++){
memset(pref, 0, sizeof(pref));
for(int j = i; j < n + 1; j++){
int s = 0;
for(int k = 1; k <= m; k++){
pref[k] += a[j][k];
s = max(pref[k], s + pref[k]);
ans = max(s, ans);
}
}
}
cout << o - ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |