제출 #1268415

#제출 시각아이디문제언어결과실행 시간메모리
1268415juan_alejandroTelefoni (COCI17_telefoni)C++20
80 / 80
10 ms2632 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define endl '\n'
#define int long long

using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(0);
    cout<<fixed;
    int n,d;
    cin>>n>>d;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        cin>>x[i];
    }
    int res=0,c=0;
    for (int i = 0; i < n-1; i++)
    {
        if(x[i]==1)
        c=0;else
        c++;
        if(c>=d)
        {
            x[i]=1;
            c=0;
            res++;
        }
    }
    /*for (int i = 0; i < n; i++)
    {
        cout<<x[i]<<" ";
    }*/
    
    cout<<res<<endl;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...