http://acm.hdu.edu.cn/showproblem.php?pid=1176
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int dp[12][100005]; //时间够多就好了。位置只有0-10 这11个位置
int main()
{
int n;
while(~scanf("%d",&n)&&n)
{
memset(dp,0,sizeof(dp));
int x,t,maxtime=0;
for(int i=0;i<n;i++)
{
scanf("%d %d",&x,&t);
dp[x][t]++;
if(t>maxtime)
maxtime = t;
}
for(int i=maxtime;i>=0;i--)
{
for(int j=0;j<=10;j++)
{
if(j == 0)
dp[j][i] += max(dp[j][i+1],dp[j+1][i+1]);
else dp[j][i] += max( max(dp[j-1][i+1],dp[j][i+1]),dp[j+1][i+1] ) ;
}
}
printf("%d\n",dp[5][0]);
}
return 0;