Codevita Max Sum Problem

Can someone kindly explain how to solve the problem “Max Sum” in Codevita using Dynamic Programming? Yes DP soln got accepted for private test cases too.

Here’s a link to the problem: https://techbomb.net/max-sum-codevita-solution-2020/