Submission #147577

#TimeUsernameProblemLanguageResultExecution timeMemory
147577KCSCTelefoni (COCI17_telefoni)C++14
80 / 80
77 ms1020 KiB
#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 timeMemoryGrader output
Fetching results...