Codeforces Dynamic programming Problem(need help)

https://codeforces.com/problemset/problem/489/C

Can anyone please help me with this dp problem …??

//