제출 #1339468

#제출 시각아이디문제언어결과실행 시간메모리
1339468ninstroyerTelefoni (COCI17_telefoni)C++20
80 / 80
9 ms1604 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long

const int nx = 3e5+5;

int n,d,res,a[nx];

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>d;
    for(int i = 1; i <= n; i++) cin>>a[i];
    int i = 2;
    int dist = 1;
    while(i<=n)
    {
        if(dist==d&&!a[i]) res++,i++,dist=1;
        else if(a[i]) dist=1,i++;
        else dist++,i++;
    }
    cout<<res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...