#P9833. Cows' Fueling Adventure
Cows' Fueling Adventure
Cows' Fueling Adventure
A group of cows has hijacked a truck and set out to explore a forest. Unfortunately, due to their terrible driving skills, the truck's fuel tank was damaged so that it leaks one unit of fuel for every unit distance traveled. To fix the tank and reach the nearest city (which is guaranteed to be within units), the cows must refuel at one of the available fuel stations located between their current position and the city. At each fuel station, they can refuel an amount between 1 and 100 units. Note that the truck's fuel tank has an infinite capacity, so there is no upper limit on the fuel it can carry.
The truck is currently units away from the city and has units of fuel. Since the truck loses one unit of fuel per unit distance traveled, the goal is to determine the minimum number of fuel stops required to reach the city. Formally, you need to find the smallest non-negative integer such that
with the additional constraint that . If no such exists, output -1.
This problem can be solved by checking if the initial fuel is enough. If not, compute the additional fuel needed and divide it by 100 (using ceiling division) to determine the minimum number of stops.
inputFormat
The input consists of a single line containing three integers , , and , where:
- $n$ is the number of fuel stations available (i.e. the maximum number of stops allowed),
- $l$ is the distance from the current location to the city,
- $p$ is the current amount of fuel in the truck.
outputFormat
Output a single integer: the minimum number of fueling stops required to reach the city. If it is impossible to reach the city under the given constraints, output -1.
sample
5 500 500
0