/ * Problem is there is a state transition equation, As long as it is not a problem to launch the equation, the first For the first gameboy for him the next second only 0-10 is moved in the eleven positions, 1 to 9 and for which he can move for the nine positions (assuming his present position x) to x + 1, or x-1, or x; 0 and two positions 10 can move only two positions, Can dp [t] [x], t seconds see pie t-1 to obtain the next position (x + 1, x, x-1) when the second Because the required maximum value of the entire process, thus seeking dp is accumulated and, Therefore, the state transition equation is dp [i] [j] + = max (dp [i + 1] [j-1], max (dp [i + 1] [j], dp [i + 1] [j + 1 ])); */ #include<cstring> #include<iostream> #include<algorithm> #include<math.h> #include<stdio.h> using namespace std; int dp[150000][20]; int main() { int n; while(scanf("%d",&n),n) { int t,x,tt=0; memset(dp,0,sizeof(dp)); for(int i=0; i<n; i++) { Scanf ( " % D% D " , X &, & T); // T is the time // X + is the position plus. 1. 1 DP [T] [X + . 1 ] ++ ; tt=max(tt,t); } int RES = 0 ; // only beginning position is determined, the time from the rear forward for ( int I = TT- . 1 ; I> = 0 ; i-- ) // Wang Qianmian pushed in this position pie number received, this position is received and coupled to the one second for ( int J = 12 is ; J> = 0 ; J, ) DP [I] [J] + = max (DP [I + . 1 ] [J- . 1 ], max (DP [I + . 1 ] [J], DP [I + . 1 ] [J + . 1 ])); // initial position 5 position, COUT << DP [ 0 ] [ . 6 ] << endl; } return 0; }