#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin >> n >> m;
int arr[n];
for(int i=0; i<n; i++) cin >> arr[i];
int next=0,ans=0;
for(int i=0; i<n; i++){
if(arr[i]==1){
next=i+m;
continue;
}
if(i==next){
ans++;
next=i+m;
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
316 KB |
Output is correct |
8 |
Correct |
13 ms |
2044 KB |
Output is correct |
9 |
Correct |
13 ms |
1988 KB |
Output is correct |
10 |
Correct |
13 ms |
1964 KB |
Output is correct |