Cod sursa(job #2411812)

Utilizator gavra_bogdanBogdan Gavra gavra_bogdan Data 21 aprilie 2019 12:36:13
Problema Zombie Scor 100
Compilator cpp-64 Status done
Runda problemegogule Marime 0.49 kb
#include <bits/stdc++.h>

using namespace std;
int v[1000005];
int main()
{
    ifstream cin("zombie.in");
    ofstream cout("zombie.out");
    int d,n,k,ans=0;
    cin>>d>>n>>k;
    for(int i=1; i<=n; i++)
        cin>>v[i];
    int st=1;
    while(st<=n)
    {
        int dr=st+1;
        while(dr<=n && d>v[dr]-v[st])
            dr++;
        if(dr-st>k)
            ans+= k;
        else
            ans+=(dr-st);
        st=dr;
    }
    cout<<ans;
    return 0;
}