Cod sursa(job #638355)
| Utilizator | Data | 20 noiembrie 2011 20:30:30 | |
|---|---|---|---|
| Problema | Zombie | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | .com 2011 | Marime | 0.5 kb |
#include <cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int d,n,k,i,j,t[1000005],stg[1000005];
int main()
{
freopen("zombie.in","r",stdin);
freopen("zombie.out","w",stdout);
scanf("%d%d%d",&d,&n,&k);
for(i=1;i<=n;i++)scanf("%d",&t[i]);
stg[1]=1;
for(i=1,j=2;j<=n;)
{
if(t[j]-t[i]>=d){i++;continue;}
stg[j]=i;j++;
}
for(i=1;i<=n;i++)
t[i]=min(t[i-1]+1,t[stg[i]-1]+k);
printf("%d\n",t[n]);
return 0;
}
