A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence ( a1a2, ..., aN) be any sequence ( ai1ai2, ..., 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
#include <iostream>
#define M 1005
using namespace std; int arr[M],dp[M],maxn;
int main()
{
int n;
while(cin>>n){
maxn = 0;
for(int i = 0; i < n; i++)
cin>>arr[i];
for(int i = 0; i < n; i++)
{
dp[i] = 1;
for(int j = 0; j < i; j++)
{
if(arr[j] < arr[i])
dp[i] = max(dp[i],dp[j]+1);
}
maxn = max(maxn,dp[i]);
} cout<<maxn<<endl;
} return 0;
}

POJ 2533 裸的LIS的更多相关文章

  1. POJ 2533 动态规划入门 (LIS)

    Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 42914 Accepte ...

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

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

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

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

  4. nyoj 17-单调递增最长子序列 && poj 2533(动态规划,演算法)

    17-单调递增最长子序列 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:21 submit:49 题目描述: 求一个字符串的最长递增子序列的长度 如 ...

  5. POJ 2533 最小上升子序列

    D - POJ 2533 经典DP-最长上升子序列 A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let th ...

  6. POJ 2533 Longest Ordered Subsequence(裸LIS)

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

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

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

  8. LIS(n^2) POJ 2533 Longest Ordered Subsequence

    题目传送门 题意:LIS(Longest Increasing Subsequence)裸题 分析:状态转移方程:dp[i] = max (dp[j]) + 1   (a[j] < a[i],1 ...

  9. POJ 2533 Longest Ordered Subsequence (LIS DP)

    最长公共自序列LIS 三种模板,但是邝斌写的好像这题过不了 N*N #include <iostream> #include <cstdio> #include <cst ...

随机推荐

  1. jquery九大选择器的用法举例

    1:基本选择器 改变 id 为 one 的元素的背景色为 #0000FF" $("#one").css("background","#000 ...

  2. QtCreator pro中相对路径和debug文件夹下未放动态库时调试报QtCreator:during startup program exited with code 0xc0000135错误

    QtCreator  pro中相对路径一般是以pro文件(非main函数所在文件)所在的当前目录为起点,用$$PWD表示. 如头文件和库文件 INCLUDEPATH +=$$PWD/inc win32 ...

  3. [springBoot系列]--springBoot注解大全[转]

    一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Configuration和@EnableAutoConfiguration ...

  4. YII2 使用phpexcel(干货)

    参考:http://www.cnblogs.com/xiaocongjiejie/p/5106249.html http://www.cnblogs.com/xiaocongjiejie/p/5106 ...

  5. 基于【CentOS-7+ Ambari 2.7.0 + HDP 3.0】搭建HAWQ数据仓库04 —— 安装HAWQ插件PXF3.3.0.0

    一. 安装PXF3.3.0.0,这里所安装的pxf的包文件都包含在apache-hawq-rpm-2.3.0.0-incubating.tar.gz里面下面步骤都是以root身份执行这里注意,pxf插 ...

  6. 用SUMIF对超15位的代码进行条件求和,出错了,原因是....

    用SUMIF对超15位的代码进行条件求和,出错了,原因是.... 2017-10-29 23:01 一.问题 有读者朋友问: 用SUMIF进行条件求和时,如果统计的条件是超15位的代码,就会出错,比如 ...

  7. Java设计模式系列之装饰者模式

    装饰者模式的定义 动态地将责任附加到对象上,若要扩展功能,装饰者提供了比继承更有弹性的替代方案  装饰者模式的UML类图 一般来说装饰者模式有下面几个参与者: Component:装饰者和被装饰者共同 ...

  8. VS2015编译rtklib2.4.2

    准备工作 在VS2015下新建一个win32的dll项目(空项目) 把在github上下载的rtklib2.4.2里的src文件夹复制到刚刚建立的win32下 把src里的文件添加到项目里,其中头文件 ...

  9. mysql 锁查询

    1.查看正在被锁定的的表 show OPEN TABLES where In_use > 0; in_use:多少个线程在使用 name_locked:是否被锁 2.查询哪些线程正在运行. 这个 ...

  10. Gym 101194A / UVALive 7897 - Number Theory Problem - [找规律水题][2016 EC-Final Problem A]

    题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?opti ...