I tried a DP approach very similar to this. Let M[i] be the marks and DP[i] be the optimal sum within A[1...i]. I also made sure that DP[i] is always greater than max(0, M[i]).
I created random inputs and compare my output with the solution in the github repo. But they didn't match.
I have some other ideas which I want to try but I really want to know why didn't this approach work.
Additionally, you think of a strategy, is there any thing which I can do to quickly check for correctness?
Thanks!