标签:
http://acm.hdu.edu.cn/showproblem.php?pid=1176
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int dp[100000+10][12];
int mat[100000+10][12];
int main()
{
int n;
int i,j,k;
int maxt;
while(scanf("%d",&n),n)
{
memset(mat,0,sizeof(mat));
memset(dp,0,sizeof(dp));
maxt=-1;
while(n--)
{
int x,y;
scanf("%d%d",&x,&y);
mat[y][x]++;
if(maxt<y) maxt=y;
}
for(i=maxt;i>=0;i--)
{
for(j=0;j<=10;j++)
{
dp[i][j]=max(dp[i+1][j],dp[i+1][j+1]);
if(j>0) dp[i][j]=max(dp[i+1][j-1],dp[i][j]);
dp[i][j]+=mat[i][j];
}
}
printf("%d\n",dp[0][5]);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/sola1994/p/4320897.html