#include <bits/stdc++.h>
using namespace std;
long long n,a[300007],ans=0,d,coun=0;
int main(){
ios_base::sync_with_stdio(0);
cin>>n>>d;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++){
if(a[i]==1) coun=0;
else coun++;
if(coun==d){
coun=0;
ans++;
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4520 KB |
Output is correct |
2 |
Correct |
0 ms |
4520 KB |
Output is correct |
3 |
Correct |
0 ms |
4520 KB |
Output is correct |
4 |
Correct |
0 ms |
4520 KB |
Output is correct |
5 |
Correct |
0 ms |
4520 KB |
Output is correct |
6 |
Correct |
0 ms |
4520 KB |
Output is correct |
7 |
Correct |
0 ms |
4520 KB |
Output is correct |
8 |
Correct |
23 ms |
4520 KB |
Output is correct |
9 |
Correct |
23 ms |
4520 KB |
Output is correct |
10 |
Correct |
19 ms |
4520 KB |
Output is correct |