Submission #206777

#TimeUsernameProblemLanguageResultExecution timeMemory
206777MrDominoOrchard (NOI14_orchard)C++14
25 / 25
178 ms8184 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, total = 0; cin >> n >> m; vector<vector<int>> a(n); for (int i = 0; i < n; i++) { a[i].resize(m); for (int j = 0; j < m; j++) { int x; cin >> x; if (x == 0) { a[i][j] = +1; } else { a[i][j] = -1; total++; } } } int sol = (int) 1e9; for (int l = 0; l < n; l++) { vector<int> sum(m, 0); for (int r = l; r < n; r++) { for (int j = 0; j < m; j++) { sum[j] += a[r][j]; } int pm = 0, p = 0; for (int j = 0; j < m; j++) { p += sum[j]; sol = min(sol, p - pm); pm = max(pm, p); } } } sol += total; cout << sol << "\n"; }
#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...