Cod sursa(job #891649)
| Utilizator | Data | 25 februarie 2013 18:36:13 | |
|---|---|---|---|
| Problema | Zombie | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.41 kb |
using namespace std;
#include<iostream>
#include<fstream>
ifstream f("zombie.in");
ofstream g("zombie.out");
int n,d,k;
int dp[1000050];
int timp[1000050];
int main()
{
int i;
f>>d>>n>>k;
int distanta=1;
for(i=1; i<=n; i++)
{
f>>timp[i];
dp[i]=dp[i-1]+1;
while( timp[distanta] < timp[i] -(d-1) )
++distanta;
dp[i]=min( dp[i] , dp[distanta-1]+k );
}
g<<dp[n];
}