Expedition SPOJ Doubt

In the implementation we’re pushing the fuel capacity for every station in the priority queue, but at the end of the code…we’re using the values even after we’re way ahead of the coordinate where the station was located. If we have already crossed that station how’re we using the fuel from there (as in the priority queue) ?

in reality this could not happen
but if you know all station and their fuel capacity then you can do this to build and algorithm

first you move ahead till when you have fuel and also keep adding fuels of stations in priority queue
once your fuels is empty you can check where should i had to fuel
and assume we have fuel this in past