Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.
The game can be played by two or more than two players. It consists of a chessboard（棋盘）and some chessmen（棋子）, and all chessmen are marked by a positive integer or “start” or “end”. The player starts from start-point and must jumps into end-point finally. In the course of jumping, the player will visit the chessmen in the path, but everyone must jumps from one chessman to another absolutely bigger (you can assume start-point is a minimum and end-point is a maximum.). And all players cannot go backwards. One jumping can go from a chessman to next, also can go across many chessmen, and even you can straightly get to end-point from start-point. Of course you get zero point in this situation. A player is a winner if and only if he can get a bigger score according to his jumping solution. Note that your score comes from the sum of value on the chessmen in you jumping path.
Your task is to output the maximum value according to the given chessmen list.
我们发现第k步的贡献等于前k - 1步的贡献 + 当前的权值；
它的子问题就是到达dp[i - p]点的最大权值。显然这满足最优子结构和无后效性
因为a[i]这个点 只能由 a[j] (j < i && a[j] < a[i])这种点转移过来，所以我们可以枚举所有在i前面的点 判断它是否 < a[i]即可；
如果a[j] < a[i] && j < i 则 dp[i] = min(dp[i], dp[j] + a[i])；
只需要在计算每个点的时候，将其dp[i] 赋值为 a[i]即可 代表其最小贡献就是自己的权值;
显然，我们需要dp[i],就需要dp[i - k] (k < i),所以我们先计算前面的点，然后转移到后面的点即可；