Cod sursa(job #636392)
Utilizator | Data | 19 noiembrie 2011 19:35:51 | |
---|---|---|---|
Problema | Zombie | Scor | 100 |
Compilator | cpp | Status | done |
Runda | .com 2011 | Marime | 0.54 kb |
#include <fstream>
using namespace std;
ifstream in("zombie.in");
ofstream out("zombie.out");
int main()
{
int pr,consum=0,i,d,k,c=0,x,n;
in>>d>>n>>k>>pr;
c=1;
for(i=2;i<=n;i++)
{
in>>x;
if(x-pr>d-1)
{
if(c>=k)
consum+=k;
else
consum+=c;
c=1;
pr=x;
}
else
c++;
}
if(c>=k)
consum+=k;
else
consum+=c;
out<<consum<<'\n';
return 0;
}