#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, d;
cin >> n >> d;
vector <int> v(n);
for(int i = 0; i < n; i++) cin >> v[i];
int sol = 0, left = d - 1;
for(int i = 1; i < n; i++, left--){
if(!left){
if(!v[i]) sol++;
left = d;
}
else if(v[i]) left = d;
}
cout << sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
2 ms |
588 KB |
Output is correct |
5 |
Correct |
2 ms |
588 KB |
Output is correct |
6 |
Correct |
2 ms |
588 KB |
Output is correct |
7 |
Correct |
2 ms |
588 KB |
Output is correct |
8 |
Correct |
21 ms |
2332 KB |
Output is correct |
9 |
Correct |
22 ms |
2820 KB |
Output is correct |
10 |
Correct |
26 ms |
2820 KB |
Output is correct |