Submission #125984

#TimeUsernameProblemLanguageResultExecution timeMemory
125984streifiOrchard (NOI14_orchard)C++14
0 / 25
83 ms10104 KiB
#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]; } int mxpos = M; int best = INF; for (int m = M; m > 0; --m) { int cur = (M-mxpos)+(cum[M]-cum[mxpos]) + (mxpos-m)-(cum[mxpos]-cum[m]) + m + cum[m]; best = min(best, cur); } cout << best << endl; }
#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...