Cod sursa(job #638755)
Utilizator | Data | 21 noiembrie 2011 16:14:16 | |
---|---|---|---|
Problema | Zombie | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<fstream>
using namespace std;
ifstream fin("zombie.in");
ofstream fout("zombie.out");
long d,k,cost,tot,i,v[1000000],n,m;
int main()
{ fin >> n >> k >> m;
for (i=1;i<=n;++i)
{ fin >> v[i];
d = d + (v[i] - v[i-1]);
++cost;
if (d >= k)
{ d = d - k;
if (cost >= m)
tot = tot + m;
else
tot = tot + cost;
cost = 0;
}
}
fout << tot;
return 0;
}