Submission #891712

#TimeUsernameProblemLanguageResultExecution timeMemory
891712ind1vTelefoni (COCI17_telefoni)C++11
80 / 80
13 ms1308 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sz(x) (int)((x).size()) #define all(x) (x).begin(), (x).end() const int N = 3e5 + 4; bool a[N]; int n, d, p, c; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> d; for (int i = 1; i <= n; ++i) { cin >> a[i]; if (i == 1) { p = i + d; } else { if (a[i] == 1) { if (p < i) { ++c; } p = i + d; } else { if (p < i) { p += d; ++c; } } } } cout << c; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...