This problem is in Contest(s) below:
Contest 1014:NOIP动态规划练习
Contest 1137:2022年暑期普及班-DP