Cod sursa(job #638350)
| Utilizator | Data | 20 noiembrie 2011 20:29:03 | |
|---|---|---|---|
| Problema | Zombie | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | .com 2011 | Marime | 0.54 kb |
#include <cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int d,n,k,i,j,t[1000001],stg[1000001];
int main()
{
freopen("zombie.in","r",stdin);
freopen("zombie.out","w",stdout);
cin>>d>>n>>k;//scanf("%d%d%d",&d,&n,&k);
for(i=1;i<=n;i++)cin>>t[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);
cout<<t[n];//printf("%d\n",t[n]);
return 0;
}
