Optimal game strategy - I

I am finding my code right on every test case I am taking----but it is only passing 1 out of 6 test cases----could not understand what is wrong with my code----

the link of my code is https://ide.codingblocks.com/s/231011

@ankur8632,
That’s because, you are greedily choosing between the leftmost and rightmost. Make sure you do Wine DP problem before attempting this one. I don’t think you understand why greedy won’t work in such problems.