#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#define int long long
#define endl '\n'
#define fr first
#define sc second
#define vc vector<int>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cout.setf(ios::fixed);
cout.precision(0);
int n, d;
cin >> n >> d;
vc num(n+1);
int pos = 1;
bool ok = true;
for(int i = 1; i <= n; i++){
cin >> num[i];
if(num[i] == 1 && num[i-1] != 0){
pos++;
}else{
ok = false;
}
}
int cont = 0;
for(int i = pos; i <= n; i += d){
if(num[i] == 0){
cont++;
}
}
cout << cont << endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |