Calvins Game(INOI) , what am I missing?

I am first running dp from k to last and finding what is the maximum sum which can be obtained an d th eposition where the maximum sum is obtained and from that position I am running a dp in backward direction till i=0; I am getting 11/17 test cases passed,don’t know what is going wrong . Please help!! INOI is 3 days away.
Problem-: CodeChef: Practical coding for everyone

Solution-: CodeChef: Practical coding for everyone

Read the problem statement carefully.

You have forgotten about a case where there might be negative outcomes. That’s it I guess.