Pagini recente » Cod sursa (job #566431) | Cod sursa (job #1622819) | Cod sursa (job #2923469) | Cod sursa (job #382886) | Cod sursa (job #1529110)
#include <fstream>
using namespace std;
int main()
{
ifstream fin ("zombie.in");
ofstream fout ("zombie.out");
ios::sync_with_stdio(false);
int d, n, k, first, zombie=1, sol=0, i, x;
fin >> d >> n >> k >> first;
for(i=2; i<=n; i++)
{
fin >> x;
if(x-first <= d) zombie++;
else
{
first=x;
if(k > zombie) sol=sol+zombie;
else sol=sol+k;
}
}
if(k > zombie) sol=sol+zombie;
else sol=sol+k;
fout << sol;
return 0;
}