not able to understand this.
Couldnt understand this question. Sir please explain this question
Let take the sample test case example for this:-
4
4 4
5 2
11 5
15 10
25 10
here the truck is at dist =25 from destination and fuel_left= 10
So the next petrol pump in its way is at dist=15 and available_fuel=10 at that petrol pump.
Since it is the nearest one so truck has to drive till there atleast for filling the petrol, and when it reaches there its fuel_left=0 because the truck required 1 unit of petrol for moving 1unit distance (distance between 25 and 15 is 10).
After reaching (15, 10), it will refill in the truck and fuel_left becomes ‘10’ now.
Now as truck moves forward it will encounter (11, 5) at that time fuel_left = 10 - 4 = 6, so we have a choice to either fill petrol from this petrol pump or go to next.
So in this way the truck will move.
@Aditikumari I hope this explanation will help you in better understanding of problem.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.