#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,d,ans=0;
int a[300001];
int main()
{
cin>>n>>d;
for(int i=1;i<=n;i++)
cin>>a[i];
int v=1;
for(int i=1;i<=n;i++)
{
if(a[i])
v=i;
else if(v+d==i)
{
v=i;
ans++;
}
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
480 KB |
Output is correct |
3 |
Correct |
2 ms |
496 KB |
Output is correct |
4 |
Correct |
2 ms |
536 KB |
Output is correct |
5 |
Correct |
2 ms |
540 KB |
Output is correct |
6 |
Correct |
2 ms |
544 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
66 ms |
2308 KB |
Output is correct |
9 |
Correct |
58 ms |
2908 KB |
Output is correct |
10 |
Correct |
60 ms |
3512 KB |
Output is correct |