Pagini recente » Cod sursa (job #3242471) | Cod sursa (job #482133) | Cod sursa (job #638420)
Cod sursa(job #638420)
#include <cstdio>
int N, D, K;
int main()
{
freopen("zombie.in", "r", stdin);
freopen("zombie.out", "w", stdout);
scanf("%d %d %d", &D, &N, &K);
int total = 0;
int x;
int closest;
int CURRENT;
int onstack = 0;
for(int i = 0; i < N; i++)
{
scanf("%d", &x);
if (onstack == 0)
{
onstack++;
closest = x;
}
else
{
if(x-closest > D)
{
if(onstack > K)
{
total += K;
}
else
{
total += onstack;
}
onstack = 1;
closest = x;
}
else
{
onstack++;
}
}
}
if(onstack > 0)
{
if(onstack > K)
{
total += K;
}
else
{
total += onstack;
}
}
printf("%d", total);
}