Submission #884044

#TimeUsernameProblemLanguageResultExecution timeMemory
884044vjudge1Telefoni (COCI17_telefoni)C++14
16 / 80
12 ms3284 KiB
#include <bits/stdc++.h>
#define ll long long
#define S second
#define F first
#define PB push_back
#define PF push_front

const int SIZE =  1e5;

using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    
    int a,b;
    cin >> a >> b;
    vector<int>V;
    
    for(int i  = 0; i < a; i++){
        int x;
        cin >> x;
        V.PB(x);
    }
    int cnt = 0;
    for(int i = 0; i < a-1; i++){
        if(V[i+1] == 0){
            bool cmp = 0;
            int x = 0;
            for(int j = i+ b; j > i; j--){
                if(V[j] == 1){
                    cmp = 1;
                    x = j;
                }
            }
            if(cmp){
                i=x;
            }
            else{
                i+=b;
                cnt++;
            }
        }
    }
    cout<<cnt;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...