[Kuangbin take you to fly] twelve thematic basis DP1 G - free pie HDU - 1176

G - free pie

HDU - 1176

Topic links: https://vjudge.net/contest/68966#problem/G

topic:

He said the sky will not fall, but one day gameboy walking down the trail back home, suddenly fall from the sky a lot a lot of pie. He says gameboy character is wonderful, this pie is not out elsewhere, they fall within a range of 10 meters beside him. If the pie out of the ground, of course not eat, so gameboy immediately remove the body bag to pick up. But because both sides of the trail can not stand, so he can only take on the trails. As the old gameboy usually I stay in the room to play games, though a nimble master in the game, but in reality the movement is particularly slow nerve, and only in the mobile per second does not exceed one meter range to catch falling pie. Now the trail as the icon coordinates:

In order to simplify the problem, assume that in the next period of time, which pies are falling 0-10 11 positions. gameboy standing position at the beginning of this 5, so the first second, he received only three positions 4,5,6 in a position where the pie. Gameboy may receive up to ask how many pies? (Assuming he's backpack can hold an infinite number of pie)

Input multiple sets of input data. The first row of each set of data to a positive integer n (0 <n <100000) , there are n represents pie out on this path. N junction down the row, each row has two integers x, T (0 <T < 100000), it shows a pie of T seconds off at the point x. The same second at the same point may fall more pie. n = 0, the input end.
Output of each set of input data corresponding to one line of output. Output an integer m, m represents gameboy can take up to a pie.
Tip: Enter data to this question than the larger, recommended read with scanf, with cin may time out.

Sample Input
6
5 1
4 1
6 1
7 2
7 2
8 3
0
Sample Output
4 
ideas: DP [t] [x] represents the number of position x at t seconds have, the process
Similar: 
. 5 (0s)
   ·. 4. 5. 6 (lS)
  . 3. 4. 5. 6. 7 (2S)
2. 3. 4. 5. 6. 7. 8 (3S)
. 1 2. 3. 4. 5. 6. 7. 8. 9 (4S)
0. 1 2. 3. 4. 5. 6 7 8 9 10 (5s)
 
//
// Created by hanyu on 2019/8/8.
//
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include<math.h>
#include<map>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
#define MAX 0x3f3f3f3f
int main()
{
    int n;
    int dp[maxn][20];
    while(~scanf("%d",&n)&&n)
    {
        memset(dp,0,sizeof(dp));
        int x,t;
        int maxt=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d%d",&x,&t);
            dp[t][x]++;
            if(t>maxt)
                maxt=t;//找出最大时间
        }
       for ( int I = maxt- . 1 ; I> = 0 ; i-- ) 
       { 
           for ( int J = 0 ; J <= 10 ; J ++ ) 
           { 
               DP [I] [J] + = max (DP [I + . 1 ] [+ J . 1 ], max (DP [I + . 1 ] [J], DP [I + . 1 ] [J- . 1 ])); // compare the current number of three positions on the maximum plus 
           } 
       } 
       the printf ( " D% \ n- " , DP [ 0 ] [ . 5 ]); 
   } 

    return  0 ; 
}

 




Guess you like

Origin www.cnblogs.com/Vampire6/p/11320507.html