Codeforces Dynamic programming Problem(need help)

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