Submission #884396

#TimeUsernameProblemLanguageResultExecution timeMemory
884396AriadnaTelefoni (COCI17_telefoni)C++14
80 / 80
34 ms2140 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; vector < int > a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } ++d; int suma = 0; for (int i = 0; i < d; ++i) { suma += a[i]; } int ans = 0; if (suma < 2 && a[0]) { a[d - 1] = 1; ++ans; ++suma; } for (int i = d; i < n; ++i) { suma += a[i] - a[i - d]; if (suma < 2 && a[i - d + 1]) { a[i] = 1; ++suma; ++ans; } } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...