标签:
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 6 const int maxn=110000; 7 8 int dp[maxn][12]; 9 int v[maxn][12]; 10 11 int max1(int a,int b,int c,int d) 12 { 13 int temp=a>b?a:b; 14 int temp1=temp>c?temp:c; 15 return temp1>d?temp1:d; 16 } 17 18 int main() 19 { 20 //freopen("in.txt","r",stdin); 21 int i,j,n,time; 22 while(scanf("%d",&n),n) 23 { 24 memset(v,0,sizeof(v)); 25 memset(dp,0,sizeof(dp)); 26 time=0; 27 for(i=0;i<n;i++) 28 { 29 int a,b; 30 scanf("%d%d",&a,&b); 31 time=max(time,b); 32 v[b][a+1]++; 33 } 34 for(i=time;i>=0;i--) 35 for(j=1;j<=11;j++) 36 dp[i][j]=max1(dp[i][j],v[i][j]+dp[i+1][j-1],dp[i+1][j]+v[i][j],dp[i+1][j+1]+v[i][j]); 37 printf("%d\n",dp[0][6]); 38 } 39 return 0; 40 }
标签:
原文地址:http://www.cnblogs.com/homura/p/4687309.html