Pagini recente » Cod sursa (job #1988993) | Clasamentul arhivei educationale | Cod sursa (job #1688801) | Borderou de evaluare (job #2785655) | Cod sursa (job #640221)
Cod sursa(job #640221)
#include <cstdio>
const int maxn=1000005;
long long n, k, d, a[maxn], first, sol, i;
int main()
{
freopen("zombie.in", "r", stdin);
freopen("zombie.out", "w", stdout);
scanf("%lld %lld %lld", &d, &n, &k);
for(i=1; i<=n; ++i) scanf("%lld", a+i);
first=1;
for(i=2; i<=n; ++i)
{
if(a[i]-a[first]>=d)
{
if(i-first>=k)
{
first=i;
sol+=k;
}
else
{
++first;
++sol;
}
}
}
if(i-first>=k) sol+=k;
else ++sol;
printf("%lld\n", sol);
return 0;
}