#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define endl '\n'
#define int long long
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout.precision(0);
cout<<fixed;
int n,d;
cin>>n>>d;
vector<int> x(n);
for (int i = 0; i < n; i++)
{
cin>>x[i];
}
int res=0,c=0;
for (int i = 0; i < n-1; i++)
{
if(x[i]==1)
c=0;else
c++;
if(c>=d)
{
x[i]=1;
c=0;
res++;
}
}
/*for (int i = 0; i < n; i++)
{
cout<<x[i]<<" ";
}*/
cout<<res<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |