Need help in this dp problem

https://community.topcoder.com/stat?c=problem_statement&pm=6572

I need help in this DP problem.Thanks in advance