#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int data[100005][11];
int temp[100005][11];
int main()
{
int n;
while(scanf("%d",&n)!=-1)
{
if(n==0) break;
memset(data,0,sizeof(data));
memset(temp,0,sizeof(temp));
int t=0;
while(n--)
{
int a,b;
scanf("%d%d",&a,&b);
data[b][a]++;
if(t<b) t=b;
}
for(int i=0;i<=10;i++)
{
temp[t][i]=data[t][i];
}
for(int i=t-1;i>=0;i--)
{
for(int j=0;j<=10;j++)
{
if(j==0) temp[i][j]=max(temp[i+1][j],temp[i+1][j+1])+data[i][j];
else if(j==10) temp[i][j]=max(temp[i+1][j],temp[i+1][j-1])+data[i][j];
else temp[i][j]=max(max(temp[i+1][j],temp[i+1][j+1]),temp[i+1][j-1])+data[i][j];
}
}
printf("%d\n",temp[0][5]);
}
return 0;
}
hdu1176 免费馅饼(变形数塔)
最新推荐文章于 2019-04-02 20:36:36 发布