# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51233 | 2018-06-17T09:38:09 Z | Kubalionzzale | Orchard (NOI14_orchard) | C++14 | 378 ms | 12544 KB |
#include <iostream> #include <vector> std::vector< std::vector<int> > g(160); #define int long long int main() { int n, m; std::cin >> n >> m; int cnt = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { int x; std::cin >> x; if (x == 0) { g[i].push_back(-1); } else { g[i].push_back(1); ++cnt; } } } if (cnt == 0) { std::cout << 0; return 0; } int maxSum = 0, lmax, rmax, topmax, bottommax; for (int i = 0; i < n; ++i) { int sum[1000010] = { 0 }; for (int k = i; k < n; ++k) { int last = 0; int curSum = 0; for (int j = 0; j < m; ++j) { sum[j] += g[k][j]; curSum += sum[j]; if (curSum < 0) { last = j + 1; curSum = 0; } else if (curSum > maxSum) { maxSum = curSum; lmax = last; rmax = j; topmax = i; bottommax = k; } } } } // std::cout << topmax << " " << bottommax << " " << lmax << " " << rmax << " " << maxSum << "\n"; int sumOfZero = 0, sumOfOne = 0; for (int i = topmax; i <= bottommax; ++i) { for (int j = lmax; j <= rmax; ++j) { if (g[i][j] == -1) ++sumOfZero; else ++sumOfOne; } } std::cout << cnt - sumOfOne + sumOfZero; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 8184 KB | Output is correct |
2 | Correct | 7 ms | 8184 KB | Output is correct |
3 | Correct | 7 ms | 8236 KB | Output is correct |
4 | Correct | 7 ms | 8312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 8480 KB | Output is correct |
2 | Correct | 10 ms | 8556 KB | Output is correct |
3 | Correct | 11 ms | 8556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 196 ms | 12368 KB | Output is correct |
2 | Correct | 197 ms | 12496 KB | Output is correct |
3 | Correct | 197 ms | 12544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 12544 KB | Output is correct |
2 | Correct | 46 ms | 12544 KB | Output is correct |
3 | Correct | 47 ms | 12544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 12544 KB | Output is correct |
2 | Correct | 79 ms | 12544 KB | Output is correct |
3 | Correct | 77 ms | 12544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 318 ms | 12544 KB | Output is correct |
2 | Correct | 378 ms | 12544 KB | Output is correct |
3 | Correct | 311 ms | 12544 KB | Output is correct |