POJ 2533 Longest Ordered Subsequence

Posted jhcelue

tags:

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

题意:求最长递增子序列

AC代码:

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int dp[1010],a[1010];
int main()
{
    int i,j,n;
    scanf("%d",&n);
    for(i=0;i<n;i++)
            scanf("%d",&a[i]);
    for(i=0;i<n;i++)
            dp[i]=1;
    if(n==1)
            printf("1\n");
    else{
            int maxx=1;
            for(i=1;i<n;i++)
            {
                for(j=0;j<i;j++)
                    if(a[j]<a[i]){
                        dp[i]=max(dp[i],dp[j]+1);

                    }
                maxx=max(dp[i],maxx);
            }
            printf("%d\n",maxx);
    }
    return 0;
}


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

POJ 2533 Longest Ordered Subsequence

POJ2533: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