Cod sursa(job #2773487)
Utilizator | Data | 7 septembrie 2021 10:29:55 | |
---|---|---|---|
Problema | Zombie | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream cin("zombie.in");
ofstream cout("zombie.out");
int d,n,k,i,a,cnt=0,first,tot=0;
cin>>d>>n>>k>>a;
first=a;
cnt=1;
for(i=0; i<n; i++)
{
cin>>a;
if(a-first<d)
cnt++;
else
{
if(cnt<k)
tot+=cnt;
else
tot+=k;
first=a;
cnt=1;
}
}
if(cnt<k)
tot+=cnt;
else
tot+=k;
cnt=1;
cout<<tot;
return 0;
}