Cod sursa(job #2412332)
Utilizator | Data | 22 aprilie 2019 08:45:49 | |
---|---|---|---|
Problema | Zombie | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | problemegogule | Marime | 0.51 kb |
#include <cstdio>
#include <algorithm>
using namespace std;
int v[1000005];
int main()
{
freopen("zombie.in","r",stdin);
freopen("zombie.out","w",stdout);
int n , d , k , cost = 0;
scanf("%d%d%d",&d,&n,&k);
for(int i = 1 ; i <= n ; i++)
scanf("%d",&v[i]);
int st=1,dr;
while(st <= n)
{
dr = st+1;
while(dr <= n && d > v[dr]-v[st])
dr++;
cost += min(dr-st,k);
st = dr;
}
printf("%d",cost);
return 0;
}