Unable to catch the bug in DP problem

I used an array named DP for storing the previously computed answers. First I copied the elements of the first row from array a to the first row of DP. And then I chose the maximum of the respective positions from the previous row of array DP and take a sum of it with the current element of array a and store this value at the respective position in array DP.
Although I passed too many test cases but still getting a wrong answer.
Please help me figuring out the bug.

Thanks in advance.
Link to the source code

Link to the problem

The following is my 10 lines of code accepted solution of this problem in C++14.

https://ideone.com/PKgRq7

Hope that this can help you in figuring out the bug in your code, if you haven’t found it yet.