Pagini recente » Cod sursa (job #112145) | Cod sursa (job #2516530) | Cod sursa (job #425846) | Cod sursa (job #267515) | Cod sursa (job #2015699)
#include<cstdio>
using namespace std;
const int nmax=1e6+5;
int st[nmax],top,bot=1,d,n,k;
int main()
{
freopen("zombie.in","r",stdin);
freopen("zombie.out","w",stdout);
int i,j;
scanf("%d%d%d",&d,&n,&k);
int x;
long long cost=0;
for(i=1;i<=n;++i)
{
scanf("%d",&x);
if(bot > top)
st[++top] =x;
else
{
if(x - st[bot] >= d)
{
//tre sa scot
if(top-bot+1 < k)
cost = cost + top-bot+1;
else
cost = cost +k;
st[++top]=x;
bot=top;
}
else
st[++top]=x;
}
}
if(top-bot+1 > 0)
{
if(top-bot+1 < k)
cost = cost + top-bot+1;
else
cost = cost + k;
}
printf("%lld",cost);
}