hdu 1176 免费馅饼

http://acm.hdu.edu.cn/showproblem.php?pid=1176

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 #define maxn 200000
 5 #define ll __int64
 6 using namespace std;
 7 
 8 ll dp[maxn][12];
 9 int n;
10 ll max1(ll a,ll b,ll c)
11 {
12     return (a>b?a:b)>c?(a>b?a:b):c;
13 }
14 
15 int main()
16 {
17     while(scanf("%d",&n)!=EOF)
18     {
19         memset(dp,0,sizeof(dp));
20         if(n==0) break;
21         int max2=-1;
22         int x,t;
23         for(int i=1; i<=n; i++)
24         {
25             scanf("%d%d",&x,&t);
26             dp[t][x+1]++;
27             max2=max(max2,t);
28         }
29         for(int i=max2; i>=0; i--)
30         {
31             for(int j=1; j<=11; j++)
32             {
33                 dp[i][j]+=max1(dp[i+1][j-1],dp[i+1][j],dp[i+1][j+1]);
34             }
35         }
36         printf("%I64d\n",dp[0][6]);
37     }
38     return 0;
39 }
View Code

 

posted @ 2014-07-27 19:53  null1019  阅读(113)  评论(0编辑  收藏  举报