#include <bits/stdc++.h>
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e6 + 7;
int n , d , a[maxn];
vector <int> pos;
void solve()
{
cin >> n >> d;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++)
{
if(a[i]) pos.push_back(i);
}
int ans = 0;
for(int i = 1; i < pos.size(); i++)
{
ans += (pos[i] - pos[i-1] - 1)/d;
}
cout << ans << '\n';
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |