Pagini recente » Cod sursa (job #450141) | Cod sursa (job #188535) | Cod sursa (job #74170) | Cod sursa (job #2469168) | Cod sursa (job #736422)
Cod sursa(job #736422)
#include <fstream>
const unsigned int SIZE(1000000);
unsigned int v [SIZE];
int main (void)
{
unsigned int d,n,k;
std::ifstream input("zombie.in");
input >> d >> n >> k;
unsigned int *it(v),*limit(v + n);
do
{
input >> *it;
++it;
}
while (it < limit);
input.close();
--limit;
unsigned int t(0),chakra(0),*aux;
it = v;
do
{
t += it[1] - *it;
if (t < d)
{
aux = it;
while (t < d && it < limit)
{
++it;
t += it[1] - *it;
}
--it;
t = 0;
if (it - aux > k)
chakra += k;
else
chakra += it - aux;
}
else
{
t = 0;
++chakra;
}
++it;
}
while (it < limit);
std::ofstream output("zombie.out");
output << chakra << '\n';
output.close();
return 0;
}