제출 #1339360

#제출 시각아이디문제언어결과실행 시간메모리
1339360apelpisiaTelefoni (COCI17_telefoni)C++20
80 / 80
10 ms716 KiB
#include <bits/stdc++.h>

using namespace std;

const int nx = 3e5+5;
int n, d, cnt = 0, l, r, ts=0;
bool phone[nx];

int main(){
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> n >> d;
    for(int i=0; i<n; i++){
        cin >> phone[i];
    }
    l=0; r=l+d-1;
    for(int i=0; i<=r; i++) ts+=phone[i];
    while(r<n){
        if(ts==0){
            phone[r] = true;
            cnt++;
            ts++;
        }
        ts-=phone[l++];
        ts+=phone[++r];
    }
    cout << cnt;

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