Need Help to avoid Wrong Answer on Spoj Problem FPOLICE

Please go through this problem FPOLICE.I wrote a recursive solution intending to somehow convert it into an iterative one. But my recursive solution gives wrong answer. I applied a simple approach explore a vertex ‘idx’ and calculate minimum risk and money associated with that ‘idx’ and ‘T’(time) and if some vertex is already visited on that path mark it so I do not have to visit it again. I have written some comments too. Can anybody please help to figure out why this code gives the Wrong answer. Code link.