Cod sursa(job #2028986)

Utilizator VladUdriVlad Udrescu VladUdri Data 28 septembrie 2017 21:43:21
Problema Zombie Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <bits/stdc++.h>

using namespace std;

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

const int NMax = 10000000;

long d, a[NMax];
int n, k, c;
short q;

int main()
{
    f >> d >> n >> k;
    for(int i = 1; i <= n; ++i){
        f >> a[i];
    }
    for(int i = 1; i <= n && !q; ++i){
        if(a[n] - a[i] >= d)
            c++;
        else
            c += k, q = 1;
    }
    g << c;
}