Cod sursa(job #640222)
| Utilizator | Data | 24 noiembrie 2011 22:36:14 | |
|---|---|---|---|
| Problema | Zombie | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.72 kb |
#include <cstdio>
#include <vector>
using namespace std;
const int maxn=1000005;
long n, k, d, first, sol, i;
vector<long> a(maxn);
int main()
{
freopen("zombie.in", "r", stdin);
freopen("zombie.out", "w", stdout);
scanf("%ld %ld %ld", &d, &n, &k);
for(i=1; i<=n; ++i) scanf("%ld", &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("%ld\n", sol);
return 0;
}
