Description

A numeric sequence of ai is ordered ifa1 <a2 < ... < aN. Let the subsequence of the given numeric sequence (a1,a2, ..., aN) be any sequence (ai1,ai2, ..., aiK), where 1 <=i1 < i2 < ... < iK <=N. For example, sequence (1, 7, 3, 5, 9, 4, 8) has ordered subsequences, e. g., (1, 7), (3, 4, 8) and many others. All longest ordered subsequences are of length 4, e. g., (1, 3, 5, 8).
Your program, when given the numeric sequence, must find the length of its longest ordered subsequence.

Input

The first line of input file contains the length of sequence N. The second line contains the elements of sequence - N integers in the range from 0 to 10000 each, separated by spaces. 1 <= N <= 1000

Output

Output file must contain a single integer - the length of the longest ordered subsequence of the given sequence.

Sample Input

7
1 7 3 5 9 4 8

Sample Output

4

//LIS比较好理解
//加油~
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std; int main()
{
int n,longest;
int a[],dp[];
while(scanf("%d",&n)!=-)
{
longest=;
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
dp[i]=;
}
for(int i=;i<n;i++)
{
for(int j=;j<i;j++)
{
if(a[i]>a[j])
dp[i]=max(dp[j]+,dp[i]);
}
longest=max(longest,dp[i]);
}
cout<<longest<<endl;
}
return ;
}

poj 2533 Longest Ordered Subsequence(LIS)的更多相关文章

  1. POJ 2533 Longest Ordered Subsequence LIS O(n*log(n))

    题目链接 最长上升子序列O(n*log(n))的做法,只能用于求长度不能求序列. #include <iostream> #include <algorithm> using ...

  2. poj 2533 Longest Ordered Subsequence 最长递增子序列

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4098562.html 题目链接:poj 2533 Longest Ordered Subse ...

  3. POJ 2533 Longest Ordered Subsequence(裸LIS)

    传送门: http://poj.org/problem?id=2533 Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 6 ...

  4. POJ 2533 Longest Ordered Subsequence(LIS模版题)

    Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 47465   Acc ...

  5. POJ 2533 - Longest Ordered Subsequence - [最长递增子序列长度][LIS问题]

    题目链接:http://poj.org/problem?id=2533 Time Limit: 2000MS Memory Limit: 65536K Description A numeric se ...

  6. Poj 2533 Longest Ordered Subsequence(LIS)

    一.Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequenc ...

  7. POJ - 2533 Longest Ordered Subsequence与HDU - 1257 最少拦截系统 DP+贪心(最长上升子序列及最少序列个数)(LIS)

    Longest Ordered Subsequence A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let ...

  8. 题解报告:poj 2533 Longest Ordered Subsequence(最长上升子序列LIS)

    Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence ...

  9. POJ 2533 Longest Ordered Subsequence(dp LIS)

    Language: Default Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submis ...

随机推荐

  1. 树莓派+Android Things

    在开始之前 谷歌前不久发布了Android Things面向物联网的系统,用意是想让android开发者用原来开发app的方式开发硬件相关的应用,扩展了android开发的方向和前景,而谷歌的Andr ...

  2. jquery validate扩展验证方法

    /***************************************************************** jQuery Validate扩展验证方法 (linjq) *** ...

  3. [转]URL的解析,C语言实现

    http://blog.csdn.net/cuishumao/article/details/10284463 一 说明(1)应用情况:比如基于socket来实现http协议等,这时候就需要解析URL ...

  4. Hadoop-2.6.0安装文档

    前段时间在dataguru上报了一个hadoop的培训班,希望能够帮助自己更快的了解.掌握并且熟悉hadoop的开发和原理. 上一期的作业是要自己搭建一个hadoop的环境,并能运行mapreduce ...

  5. HDU 3362 Fix(状压dp)

    Fix Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submi ...

  6. TortoiseGit 错误信息Aborting commit due to empty commit message.解决

    错误信息: Aborting commit due to empty commit message. git不能完全退出(退出码 1) (47 ms @ 2016/2/19 14:03:24) 解决办 ...

  7. php之soap使用

    1,首先要在linux服务器安装php的soap拓展,最快的方式是yum安装: #yum install php-soap 然后重启apache即可 2,php调用soap接口 try{ $soap ...

  8. CentOS6.3添加nginx系统服务详细说明

    今天虚拟机上配了下服务器整理了个这个 nginx 服务 要注意 - 短横杠这个符号看看复制进去后有没有乱码,我之前就遇到这个问题,郁闷了好久才发现 提示:顶部的注释不要去除否则无法注册为系统服务, 关 ...

  9. js--闭包的理解

    从技术上来讲,在JS中,每个function都是闭包,因为它总是能访问在它外部定义的数据. 当该内部函数在外部函数外被调用,就生成了闭包. 函数内部可以直接读取全局变量. 闭包就是能够读取其他函数内部 ...

  10. hdu_5890_Eighty seven(bitset优化DP)

    题目链接:hdu_5890_Eighty seven 题意: 50个数,10W个询问,每次问删掉第i,j,k个数后,是否存在一种选10个数和为87的方案,只需要输出 ’Yes’ 或者 ’No’ 题解: ...