Poj 2533 Longest Ordered Subsequence

Posted lusiqi

tags:

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

技术图片

 

 代码:

#include<iostream>
#include<stdio.h>
using namespace std;
const int maxn = 1001;
int a[maxn],dp[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        dp[i] =1;
    }    
    int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[j]>a[i]){
                dp[j] = max(dp[j],dp[i]+1);
            }
        }
    }
    for(int i=1;i<=n;i++)
        ans = max(ans,dp[i]); 
    cout<<ans<<endl; 
    return 0;
}

 

以上是关于Poj 2533 Longest Ordered Subsequence的主要内容,如果未能解决你的问题,请参考以下文章

POJ2533:Longest Ordered Subsequence

POJ 2533 Longest Ordered Subsequence

poj 2533 Longest Ordered Subsequence(LIS)

POJ 2533 Longest Ordered Subsequence(裸LIS)

POJ 2533 Longest Ordered Subsequence DP

POJ - 2533 Longest Ordered Subsequence