Cod sursa(job #1650124)
| Utilizator | Data | 11 martie 2016 16:43:20 | |
|---|---|---|---|
| Problema | Zombie | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream f("zombie.in");
ofstream g("zombie.out");
unsigned long long N, D, K, activeZ, st, sol, x;
int main()
{
f >> D >> N >> K;
for(int i = 1; i <= N; i++){
f >> x;
if(x - st <= D - 1){
activeZ++;
continue;
}
sol += activeZ > K ? K : activeZ;
activeZ = 1;
st = x;
}
sol += activeZ > K ? K : activeZ;
g << sol;
return 0;
}
