免费馅饼

Posted wsy107316

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了免费馅饼相关的知识,希望对你有一定的参考价值。

免费馅饼技术图片

 

 技术图片

 

 数字三角形变形:

AC_Code

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <string>
 5 #include <cmath>
 6 #include <algorithm>
 7 using namespace std;
 8 const int maxn = 100010;
 9 int n,mt,x,t;
10 
11 int dp[maxn][13];
12 int a[maxn][13];
13 int main()
14 {
15     int n,id,t,maxx=-1;
16     while( ~scanf("%d",&n) && n){
17         memset(dp,0,sizeof(dp));
18         memset(a,0,sizeof(a));
19         maxx = -1;
20         while( n-- ){
21             scanf("%d %d",&id,&t);
22             a[t][id]++;
23             if( t>maxx ) maxx = t;
24         }
25 
26         for(int i=0; i<=11; i++){
27             dp[maxx][i]=a[maxx][i];
28         }
29 
30         for(int i=maxx-1;i>=0;i--){
31             for(int j=0;j<=11;j++){
32                 dp[i][j] = a[i][j] + max(dp[i+1][j],max(dp[i+1][j-1],dp[i+1][j+1]));
33             }
34         }
35         printf("%d
",dp[0][5]);
36     }
37     return 0;
38 }

 

以上是关于免费馅饼的主要内容,如果未能解决你的问题,请参考以下文章

免费馅饼

免费馅饼

免费馅饼

hdu 1176 免费馅饼

nyoj 613 免费馅饼

HDU-1176 免费馅饼 ( DP )