# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
485688 | KazamaHoang | Telefoni (COCI17_telefoni) | C++14 | 25 ms | 3244 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n, d, a[300005], s[300005], res = 0;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> d;
for (int i = 1; i <= n; ++ i) {
cin >> a[i];
s[i] = s[i-1] + a[i];
}
for (int i = 1; i < n;) {
if (a[i] == 1) {
int mx = min(n, i + d);
if (s[mx] - s[i]) {
++ i;
} else {
++ res;
a[mx] = 1;
i = mx;
}
} else ++ i;
}
cout << res;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |