One test cases failing for expedi problem please help!

code link -> https://ide.codingblocks.com/s/237887

for the given code one testcase passes but other one fails

also in the given problem statement no output format is shown if cows are not able to reach in town , I considered it to be -1
as from the spoj 's website

please help

can someone look into it?

Hey @anmol1911
Your code is getting stuck in an infinite loop
Try to see once where else I’ll help you
Q : 4
4 5
5 10
11 5
15 12
25 10

A : 2

Hi, for the following test case the code is running and giving output as 1 not 2 , but it is not perpetual loop
but i am not able to find the mistake yet

@anmol1911
Might have been an IDE issue at my time for loop thing. Sorry for that.
After processing all N stations, you didn’t check if the van has reached the end
You need to check if you have enough fuel to reach end still