# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
884396 | Ariadna | Telefoni (COCI17_telefoni) | C++14 | 34 ms | 2140 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 main()
{
int n, d;
cin >> n >> d;
vector < int > a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
++d;
int suma = 0;
for (int i = 0; i < d; ++i) {
suma += a[i];
}
int ans = 0;
if (suma < 2 && a[0]) {
a[d - 1] = 1;
++ans;
++suma;
}
for (int i = d; i < n; ++i) {
suma += a[i] - a[i - d];
if (suma < 2 && a[i - d + 1]) {
a[i] = 1;
++suma;
++ans;
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |