Pagini recente » Cod sursa (job #111348) | Arhiva de probleme | Istoria paginii noul-infoarena | Istoria paginii info-oltenia-2019 | Cod sursa (job #1566330)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("zombie.in");
ofstream fout("zombie.out");
int main(){
int n, d, k, last, pos, x, cost;
fin >> d >> n >> k >> last;
pos = 1;
cost = 0;
for(int i = 2; i <= n; i++){
fin >> x;
if(x - last > d){
if(i - pos >= k){
cost += k;
} else {
cost += (i - pos);
}
last = x;
pos = i;
}
}
if(n - pos >= k){
cost += k;
} else {
cost += (n - pos);
}
fout << cost;
return 0;
}