This problem is in Contest(s) below:
Contest 1014:NOIP动态规划练习
Contest 1071:长训班动规专题