zoukankan      html  css  js  c++  java
  • poj 1609 dp

    题目链接:http://poj.org/problem?id=1609

    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <cmath>
    #include <algorithm>
    #include <queue>
    #include <vector>
    using namespace std;
    
    const int maxe = 50000;
    const int maxn = 105;
    const int INF  = 0x3f3f3f;
    
    
    int main()
    {
        //freopen("E:\acm\input.txt","r",stdin);
        int N;
        int dp[maxn][maxn];
        int B[maxn][maxn];
        int Maxl,Maxm;
        while(cin>>N){
            memset(dp,0,sizeof(dp));  //dp[i][j]表示最大的l为i,m为j的高度
            memset(B,0,sizeof(B));
            Maxl = 0, Maxm = 0;
    
            if(N == 0)  {  printf("*
    ");  break;   }
            for(int i=1;i<=N;i++){
                int a,b;
                scanf("%d %d",&a,&b);
                Maxl = max(Maxl,a);
                Maxm = max(Maxm,b);
                B[a][b]++;
            }
            int ans = 0;
            for(int i=1;i<=Maxl;i++)
              for(int j=1;j<=Maxm;j++){
                 dp[i][j] = B[i][j] + max(dp[i-1][j] , dp[i][j-1] );
                 if(B[i][j])  ans = max(ans,dp[i][j]);
            }
            printf("%d
    ",ans);
        }
    }
    View Code
  • 相关阅读:
    毕业论文格式
    2018.12.14
    关于百度搜索引擎的优缺点
    2018.12.13
    2018.12.12
    2018.12.11
    2108.12.10
    2018.12.9
    2018.12.8
    2018.12.7
  • 原文地址:https://www.cnblogs.com/acmdeweilai/p/3277391.html
Copyright © 2011-2022 走看看