This problem is in Contest(s) below:
Contest 1849:B班dp
Contest 1855:湖塘实验中学动态规划作业
Contest 1571:noip
Contest 1386:2017.7C长训班2第9课作业
Contest 1861:动态规划最后一天题目