zoukankan      html  css  js  c++  java
  • hdu1176

    /*
    数塔变形
    一看代码 就明白
    
    6
    5 1
    4 1
    6 1
    7 2
    7 2
    8 3
    0
    
    4
    */
    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    using namespace std;
    int dp[100002][11];
    int main()
    {
        int n;
        int t,pos;
        int max_t=0;
        while(scanf("%d",&n),n!=0)
        {
            memset(dp,0,sizeof(dp));
            for(int i=0;i<n;i++)
            {
                scanf("%d %d",&pos,&t);
                dp[t][pos]++;
                if(max_t<t)max_t = t;
            }
            for(int i=max_t;i>=0;i--)
            {
                dp[i][0] += max(dp[i+1][1],dp[i+1][0]);
                dp[i][10] += max(dp[i+1][9],dp[i+1][10]);
                for(int j=1;j<10;j++)
                    dp[i][j] += max(max(dp[i+1][j-1],dp[i+1][j]),dp[i+1][j+1]);
            }
            printf("%d\n",dp[0][5]);
        }
    
        return 0;
    }
  • 相关阅读:
    C#泛型
    C#接口
    C#委托和事件
    Unity Ray 射线
    C#学习基础
    Graph | Eulerian path
    Careercup | Chapter 8
    Leetcode | Pow(x, n)
    Leetcode | Gray code
    分布式缓存
  • 原文地址:https://www.cnblogs.com/xibaohe/p/3016991.html
Copyright © 2011-2022 走看看