This problem is in Contest(s) below:
Contest 1279:dp入门
Contest 1465:Dp入门
Contest 1270:Dp入门及记忆化搜索
Contest 1444:Dp入门