Submission #485688

#TimeUsernameProblemLanguageResultExecution timeMemory
485688KazamaHoangTelefoni (COCI17_telefoni)C++14
80 / 80
25 ms3244 KiB
#include <bits/stdc++.h> using namespace std; int n, d, a[300005], s[300005], res = 0; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> d; for (int i = 1; i <= n; ++ i) { cin >> a[i]; s[i] = s[i-1] + a[i]; } for (int i = 1; i < n;) { if (a[i] == 1) { int mx = min(n, i + d); if (s[mx] - s[i]) { ++ i; } else { ++ res; a[mx] = 1; i = mx; } } else ++ i; } cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...