Help required in this DP problem (from SPOJ)

solution giving wrong answer

@galencolin can you please tell where my solution is wrong ??

Also if anyone can share the AC code , it would be a great help


Quick tip: get rid of doubles, precision is bad (you can double all values, work with ints, then divide the answer by 2 at the end). That’s probably not the issue though.

Can you explain what you’re doing in the code? It’s super long.

1 Like

in function solve() : - i am trying to find the maximum benefit .
in go() :- here i am trying to find the minimum cost for the maximum benefit calculated from solve().
in path() :- indexes whose sum of cost value is minimum and summation of the benefits is equal to
maximum benefit possible calculated from solve().