Cod sursa(job #1529110)

Utilizator tudormaximTudor Maxim tudormaxim Data 20 noiembrie 2015 15:37:22
Problema Zombie Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
using namespace std;
int main()
{
    ifstream fin ("zombie.in");
    ofstream fout ("zombie.out");
    ios::sync_with_stdio(false);
    int d, n, k, first, zombie=1, sol=0, i, x;
    fin >> d >> n >> k >> first;
    for(i=2; i<=n; i++)
    {
        fin >> x;
        if(x-first <= d) zombie++;
        else
        {
            first=x;
            if(k > zombie) sol=sol+zombie;
            else sol=sol+k;
        }
    }
    if(k > zombie) sol=sol+zombie;
    else sol=sol+k;
    fout << sol;
    return 0;
}