#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n, d;
cin >> n >> d;
ll cnt1 = 0, cnt2 = 0;
for (ll i = 0; i < n; ++i) {
bool b;
cin >> b;
if (b) {
if (cnt2) {
cnt1 += cnt2 / d;
cnt2 = 0;
}
} else {
++cnt2;
}
}
cout << cnt1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
24 ms |
896 KB |
Output is correct |
9 |
Correct |
27 ms |
1024 KB |
Output is correct |
10 |
Correct |
22 ms |
1024 KB |
Output is correct |