This problem is in Contest(s) below:
Contest 1008:基础动态规划
Contest 1334:2024春C++周日早第8期