This problem is in Contest(s) below:
Contest 1295:动态规划1
Contest 1359:动态规划基本型
Contest 1369:动态规划基本型