sinhadiptiprakash's blog

By sinhadiptiprakash, history, 2 weeks ago, In English

Hey, I just found a problem on spoj EXPEDI — Expedition which is a greedy problem and I came to know that the problem can be solved by using heap(max) data structure. But I was unable to figure out how this problem can be solved using heap. I am new to programming so, please help me with some explanation how to approach this problem with heap. I am eager to learn. Thanks a lot in advance.

  • Vote: I like it
  • -4
  • Vote: I do not like it

2 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I think that you start from source and as you are going towards destination, keep track of all the stations in between. As soon as you see that you don't have fuel then greedily, we can take the max fuel and move forward.