Piyush And magical park maximum value

i am unable to find the maximum strength that he can gather in the park in a new line. plzz check my code
https://ide.codingblocks.com/s/75553