#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// https://codeforces.com/blog/entry/79148
class Timer: chrono::high_resolution_clock {
const time_point start_time;
public:
Timer(): start_time(now()) {}
rep elapsed_time() const {
return chrono::duration_cast<chrono::milliseconds>(now() - start_time).count();
}
} timer;
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int n, d, pr, ans = 0;
cin >> n >> d;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x) {
pr = i;
}
if (i - pr == d) {
ans++;
pr = i;
}
}
cout << ans;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |