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<bits/stdc++.h>
using namespace std;
const int mxN = 1;
const int mxM = 1e6 + 6;
int grid[mxM], pref[mxM];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
for(int i = 1;i <= m;++i){
cin >> grid[i];
pref[i] = pref[i - 1] + grid[i];
}
set<int>s;
s.insert(0);
int mn = 1e9;
for(int i = 1;i <= m;++i){
auto itr = s.begin();
mn = min(mn, i - 2 * pref[i] + pref[m] + 1 + *itr);
s.insert(2 * pref[i - 1] - i);
}
cout << mn;
}
# | 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... |