Submission #691808

#TimeUsernameProblemLanguageResultExecution timeMemory
691808phathnvOrchard (NOI14_orchard)C++11
25 / 25
164 ms10100 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; vector<vector<int>> a(n, vector<int>(m)); int num1 = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> a[i][j]; num1 += a[i][j]; } } int res = num1; vector<int> s(m); for (int x1 = 0; x1 < n; ++x1) { fill(s.begin(), s.end(), 0); for (int x2 = x1; x2 < n; ++x2) { int cur = 0, sum = 0; for (int i = 0; i < m; ++i) { sum += (a[x2][i]? -1 : +1); s[i] += sum; res = min(res, num1 + s[i] - cur); cur = max(cur, s[i]); } } } cout << res << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...