Longest Ordered Subsequence POJ - 2533

原创 2018年04月15日 19:26:03

Longest Ordered Subsequence POJ - 2533
求最长上升序列。emmm模板题注意一下输出一开始赋初值:ans=1。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
const int maxn=1000+10;
int a[maxn];
int dp[maxn];
using namespace std;
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
        int ans=1;
        dp[0]=1;
        for(int i=1;i<n;i++)
        {
            dp[i]=1;
            for(int j=0;j<i;j++)
            {
                if(a[i]>a[j]&&dp[i]<dp[j]+1)
                dp[i]=dp[j]+1;
            }
            ans=max(ans,dp[i]);
        }
        printf("%d\n",ans);
    }
}
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Miranda_ymz/article/details/79952099

POJ Problem 2533 Longest Ordered Subsequenc

求最长递增子序列的长度 动态规划法,算法复杂度为O(nlogn) #include #include #include #include using namespace std; int m...
  • linian8123654
  • linian8123654
  • 2016-11-06 15:38:05
  • 88

Pku acm 第2533题 Longest Ordered Subsequence 代码,有详细的注释

  • 2008年01月01日 20:09
  • 549B
  • 下载

HOJ 10027 Longest Ordered Subsequence Extention

Longest Ordered Subsequence Extention Time Limit: 1000ms, Special Time Limit:2500ms, Memory Lim...
  • u013595779
  • u013595779
  • 2014-04-16 17:14:38
  • 823

N - Longest Ordered Subsequence——POJ 最长递增子序列

N - Longest Ordered Subsequence Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64...
  • chudongfang2015
  • chudongfang2015
  • 2016-05-19 10:47:44
  • 428

POJ2533:Longest Ordered Subsequence(LIS)

Description A numeric sequence of ai is ordered if a1 a2 aN. Let the subsequence of the given nume...
  • libin56842
  • libin56842
  • 2013-07-29 20:50:53
  • 4276

Longest Ordered Subsequence

  • 2009年12月17日 11:03
  • 10KB
  • 下载

动态规划【Longest Ordered Subsequence】

Description A numeric sequence of ai is ordered if a1 a2 aN. Let the subsequence of the given n...
  • u012970471
  • u012970471
  • 2014-04-25 20:43:29
  • 686

POJ 2533-Longest Ordered Subsequence(dp_最长上升子序列)

Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissi...
  • u013486414
  • u013486414
  • 2015-02-02 21:04:13
  • 466

poj-2533 Longest Ordered Subsequence 【最长上升子序列】

题目链接:http://poj.org/problem?id=2533 Longest Ordered Subsequence Time Limit: 2000MS   ...
  • u014427196
  • u014427196
  • 2015-03-01 16:56:46
  • 479

Longest Ordered Subsequence-POJ2533 <O(nlog(n))算法>

Longest Ordered SubsequenceTime Limit: 2000MS Memory Limit: 65536K Total Submissions: 45282 ...
  • STILLxjy
  • STILLxjy
  • 2016-07-12 18:20:22
  • 249
收藏助手
不良信息举报
您举报文章:Longest Ordered Subsequence POJ - 2533
举报原因:
原因补充:

(最多只允许输入30个字)