Maximum sum query

https://ide.codingblocks.com/s/173318 ,all test cases are coming wrong…but sample input is correct,plzz tell what is wrong in code??

Your approach is wrong.
You can read more here for better understanding.