HDU 1176

 1 /*
 2 
 3        5      //起点 
 4     4 5 6
 5   3 4 5 6 7
 6 2 3 4 5 6 7 8
 7     .
 8     .
 9     .
10 
11 
12 看了此表 ,天啊我好蠢 = = 
13 数塔, 自底向上计算, 因为边界问题所以点全都向右移了一下 = = 
14 
15 #include<cstdio>
16 #include<algorithm>
17 #include<cstring>
18 using namespace std;
19 const int maxn=100005;
20 int dp[maxn][15],a[maxn][15],n;
21 int main()
22 {
23     while(scanf("%d",&n)!=EOF && n)
24     {
25         memset(dp,0,sizeof(dp));
26         memset(a,0,sizeof(a));
27         int tm=-1,x,t;
28         for(int i=1;i<=n;i++)
29         {
30             scanf("%d%d",&x,&t);
31             a[t][x+1]++;
32             tm = max(tm,t);
33         }
34         for(int i=tm;i>=0;i--)
35         {
36             for(int j=1;j<=11;j++)
37             {
38                 for(int k=-1;k<=1;k++)
39                 dp[i][j] = max(dp[i][j],a[i][j] + dp[i+1][j+k]);
40             }
41         }
42         printf("%d
",dp[0][6]);
43     }
44     return 0;
45 }
46 
47 
48 
49 
50 */
原文地址:https://www.cnblogs.com/ember/p/5317429.html