Submission #147577

# Submission time Handle Problem Language Result Execution time Memory
147577 2019-08-30T07:20:12 Z KCSC Telefoni (COCI17_telefoni) C++14
80 / 80
77 ms 1020 KB
#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
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 392 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 75 ms 888 KB Output is correct
9 Correct 77 ms 888 KB Output is correct
10 Correct 76 ms 1020 KB Output is correct