#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2524 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
10068 KB |
Output is correct |
2 |
Correct |
66 ms |
10068 KB |
Output is correct |
3 |
Correct |
64 ms |
10252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
7004 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |