This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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> cum(M+2, 0);
for (int m = 0; m < M; ++m) {
int X;
cin >> X;
cum[m+1] = cum[m]+X;
}
cum[M+1] = cum[M];
int fee = INF;
for (int i = 0; i <= M; ++i) {
for (int j = i+1; j <= M+1; ++j) {
int a = cum[i];
int b = (j-i)-(cum[j]-cum[i]);
//cout << b << endl;
int c = cum[M+1]-cum[j];
fee = min(fee, a+b+c);
}
}
cout << fee << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |