# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147577 | KCSC | Telefoni (COCI17_telefoni) | C++14 | 77 ms | 1020 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;
vector<int> lst;
int main(void) {
int n, d;
cin >> n >> d;
for (int i = 1; i <= n; ++i) {
int x;
cin >> x;
if (x == 1)
lst.push_back(i);
}
reverse(lst.begin(), lst.end());
int v = 1, nr = 0;
for (; lst.size(); lst.pop_back()) {
while (abs(lst.back() - v) > d) {
++nr;
v += d;
}
v = lst.back();
}
cout << nr;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |