Problem
You are driving through N towns along a highway. Between consecutive towns, the car uses fuel[i] litres of petrol to go from town i to town i+1.
You start with F litres in the tank. At any town you can stop and refuel, adding R litres to your tank.
Find the minimum number of refuelling stops needed to reach town N from town 1.
Greedy rule: only refuel when you don't have enough fuel to reach the next town!
You start with F litres in the tank. At any town you can stop and refuel, adding R litres to your tank.
Find the minimum number of refuelling stops needed to reach town N from town 1.
Greedy rule: only refuel when you don't have enough fuel to reach the next town!
Input Variables (pre-loaded)
š” Drag N, F, R, and fuel for segment i from Inputs.
Your Output
Result
ā
Run your program to see the result.
Execution Log
Ready. Press ā¶ Run to start.
Expected Answer
Answer:
?
Hint
Step 0