MAXIMUM Sum Query

This is my code for the problem : https://online.codingblocks.com/player/20736/content/4995/4867

None of my test cases are passing. Please guide