Cod sursa(job #2024833)

Utilizator dumitrescu_andreiDumitrescu Andrei dumitrescu_andrei Data 21 septembrie 2017 11:46:52
Problema Zombie Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("zombie.in");
ofstream g("zombie.out");

int a[1000001],d,n,k;

int main()
{
    f>>d>>n>>k;

    for(int i=1;i<=n;++i)
        f>>a[i];

    int i=1,s=0;
    while(i<=n)
    {
        int poz=i;
        while(i<n && a[i+1]-a[poz]<=d-1)
            i++;

        s+=min(k,i-poz+1);

        i++;

    }

    g<<s;

    return 0;
}