• 免费馅饼


    免费馅饼

     

     数字三角形变形:

    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 }
  • 相关阅读:
    关于input()
    HDU 3746
    HDU 4335 Contest 4
    HDU 4418 高斯消元法求概率DP
    HDU 4339 Contest 4
    HDU 4334 Contest 4
    HDU 4333 Contest 4
    HDU 4332 Contest 4
    HDU 4035
    HDU 4336
  • 原文地址:https://www.cnblogs.com/wsy107316/p/12244209.html
Copyright © 2020-2023  润新知