# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
125994 |
2019-07-06T17:01:41 Z |
streifi |
Orchard (NOI14_orchard) |
C++14 |
|
82 ms |
10236 KB |
#include <iostream>
#include <vector>
using namespace std;
const int INF = 0x3f3f3f3f;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N, M;
cin >> N >> M;
vector<int> v(M), cum(M+1, 0);
for (int m = 0; m < M; ++m) {
cin >> v[m];
if (v[m] == 0) v[m] = -1;
cum[m+1] = cum[m]+v[m];
//cout << cum[m+1] << endl;
}
int mxpos = M-1;
int best = INF;
for (int m = M-1; m >= 0; --m) {
if (cum[m+1] > cum[mxpos+1])
mxpos = m;
int cur1 = (M-mxpos-1)+(cum[M]-cum[mxpos+1]);
int cur2 = (mxpos-m+1)-(cum[mxpos+1]-cum[m]);
int cur3 = m + cum[m];
//cout << cur1 << " " << cur2 << " " << cur3 << endl;
best = min(best, cur1+cur2+cur3);
}
cout << best/2 << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
8184 KB |
Output is correct |
2 |
Correct |
82 ms |
10076 KB |
Output is correct |
3 |
Correct |
82 ms |
10236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |