Cod sursa(job #639542)

Utilizator rzvrzvNicolescu Razvan rzvrzv Data 23 noiembrie 2011 15:15:22
Problema Zombie Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include<cstdio>
#define INF = 0x3f3f3f3f;
using namespace std;

int d,n,k,a[1000003],b[1000003];

int main()
{
    freopen("zombie.in","r",stdin);
    freopen("zombie.out","w",stdout);
    scanf("%d%d%d",&d,&n,&k);
    int i,lmt;
    lmt=1;
    b[0]=0;
    for (i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=b[i-1]+16;
        while(a[lmt]<a[i]-d+1)
            lmt++;
        if (b[i]>b[lmt-1]+k)
            b[i]=b[lmt-1]+k;
    }
    printf("%d\n",b[n]);
    return 0;
}