Cod sursa(job #637060)
Utilizator | Data | 20 noiembrie 2011 11:16:52 | |
---|---|---|---|
Problema | Zombie | Scor | 100 |
Compilator | cpp | Status | done |
Runda | .com 2011 | Marime | 0.44 kb |
#include<cstdio>
#define minim(a,b) a<b?a:b
void read(),solve();
int n,k,i,st,A[1000010],cost[1000010],d;
int main()
{
read();
solve();
return 0;
}
void read()
{
freopen("zombie.in","r",stdin);
freopen("zombie.out","w",stdout);
scanf("%d%d%d",&d,&n,&k);
}
void solve()
{
st=1;
for(i=1;i<=n;i++)
{
scanf("%d",&A[i]);
while(A[st]+d<A[i])st++;
cost[i]=minim(cost[i-1]+1,cost[st-1]+k);
}
printf("%d\n",cost[n]);
}