# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
14515 |
2015-05-19T04:37:13 Z |
nosiar |
Orchard (NOI14_orchard) |
C++14 |
|
202 ms |
13436 KB |
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;
vector<vector<int>> sum;
int n, m;
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
ios::sync_with_stdio(false); //int tests; cin >> tests; for (int cc = 0; cc < tests; ++cc)
{
cin >> n >> m;
sum = vector<vector<int>>(n+1, vector<int>(m+1));
int num_one = 0;
for (int i = 1; i <= n; ++i)
{
for (int j = 1; j <= m; ++j)
{
cin >> sum[i][j]; if (!sum[i][j]) sum[i][j] = -1; else num_one++;
sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
}
}
int global_max_sum = 0;
for (int i = 0; i < n; ++i)
{
for (int j = i + 1; j <= n; ++j)
{
int max_sum = 0;
int min_sum = 0;
for (int k = 1; k <= m; ++k)
{
int cur_sum = sum[j][k] - sum[i][k];
max_sum = max(max_sum, cur_sum - min_sum);
min_sum = min(min_sum, cur_sum);
}
global_max_sum = max(global_max_sum, max_sum);
}
}
cout << num_one - global_max_sum << endl;
}}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1712 KB |
Output is correct |
2 |
Correct |
0 ms |
1712 KB |
Output is correct |
3 |
Correct |
0 ms |
1712 KB |
Output is correct |
4 |
Correct |
0 ms |
1712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1892 KB |
Output is correct |
2 |
Correct |
0 ms |
1892 KB |
Output is correct |
3 |
Correct |
0 ms |
1892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
13436 KB |
Output is correct |
2 |
Correct |
102 ms |
13436 KB |
Output is correct |
3 |
Correct |
110 ms |
13436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
3280 KB |
Output is correct |
2 |
Correct |
18 ms |
3280 KB |
Output is correct |
3 |
Correct |
22 ms |
3280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1844 KB |
Output is correct |
2 |
Correct |
6 ms |
1844 KB |
Output is correct |
3 |
Correct |
6 ms |
1844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
200 ms |
4728 KB |
Output is correct |
2 |
Correct |
192 ms |
4728 KB |
Output is correct |
3 |
Correct |
202 ms |
4728 KB |
Output is correct |