Submission #1055279

#TimeUsernameProblemLanguageResultExecution timeMemory
1055279fryingducTelefoni (COCI17_telefoni)C++17
80 / 80
8 ms2144 KiB
/* #pragma GCC optimize("Ofast,unroll-loops") */
#include "bits/stdc++.h"
using namespace std;

#ifdef duc_debug
#include "bits/debug.h"
#else 
#define debug(...)     
#endif

/* #define int long long */

const int mod = 300'007;
int n, d, a[mod];
void solve(){
    cin >> n >> d;
    for(int i = 1; i <= n; i++) cin >> a[i];
    int ans = 0, last_one = 1;
    for(int i = 2; i <= n; i++){
        if(i - last_one >= d){
            if(a[i] == 0) ans++;
            a[i] = 1;
        }
        if(a[i] == 1) last_one = i;
    }
    cout << ans;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int test = 1;
    /* cin >> test; */
    for(int i = 1; i <= test; i++){
        /* cout << "Case " << "#" << i << ": "; */
        solve();
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...