Pagini recente » Cod sursa (job #2259085) | Monitorul de evaluare | Cod sursa (job #2781247) | Cod sursa (job #3314011) | Cod sursa (job #3306810)
#include <fstream>
using namespace std;
int main() {
ifstream fin("zombie.in");
ofstream fout("zombie.out");
int d, n, k, a, b, cnt, cost;
fin >> d >> n >> k;
fin >> b;
cnt = 1;
cost = 0;
for(int i = 1; i < n; i ++) {
fin >> a;
if(d - (a - b) < 0) {
if(cnt < k)
cost = cost + cnt;
else
cost = cost + k;
cnt = 1;
b = a;
}
else {
cnt ++;
}
}
if(cnt < k)
cost = cost + cnt;
else
cost = cost + k;
fout << cost;
return 0;
}