poj 2533 Longest Ordered Subsequence(LIS)
Description
Your program, when given the numeric sequence, must find the length of its longest ordered subsequence.
Input
Output
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)的更多相关文章
- POJ 2533 Longest Ordered Subsequence LIS O(n*log(n))
题目链接 最长上升子序列O(n*log(n))的做法,只能用于求长度不能求序列. #include <iostream> #include <algorithm> using ...
- poj 2533 Longest Ordered Subsequence 最长递增子序列
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4098562.html 题目链接:poj 2533 Longest Ordered Subse ...
- POJ 2533 Longest Ordered Subsequence(裸LIS)
传送门: http://poj.org/problem?id=2533 Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 6 ...
- POJ 2533 Longest Ordered Subsequence(LIS模版题)
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 47465 Acc ...
- POJ 2533 - Longest Ordered Subsequence - [最长递增子序列长度][LIS问题]
题目链接:http://poj.org/problem?id=2533 Time Limit: 2000MS Memory Limit: 65536K Description A numeric se ...
- Poj 2533 Longest Ordered Subsequence(LIS)
一.Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequenc ...
- POJ - 2533 Longest Ordered Subsequence与HDU - 1257 最少拦截系统 DP+贪心(最长上升子序列及最少序列个数)(LIS)
Longest Ordered Subsequence A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let ...
- 题解报告:poj 2533 Longest Ordered Subsequence(最长上升子序列LIS)
Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence ...
- POJ 2533 Longest Ordered Subsequence(dp LIS)
Language: Default Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submis ...
随机推荐
- apue学习记录——配置apue.3e,实现P4‘ls例子
#include"apue.h" #include<dirent.h> int main(int argc,char *argv[]) { DIR *dp; struc ...
- python如何保证多个线程同时修改共享对象时不出错!
import threadingimport timenumber = 0lock = threading.RLock() #是Lock()的升级版,用Rlock()即可def run(num): l ...
- Jenkins中集成Gcov代码覆盖率报告
最近终于把gcov代码覆盖报告集成到jenkins中了,总算是完成工作,写篇博客总结下. 我循序渐进地用了三个工具:gcov, lcov, gcovr 这三个工具原理(其实gcovr依赖于GNU的gc ...
- jquery 学习笔记(1)
$就是jquery的一个简写形式 如$('#foo')和jQuery('#foo')是等价的, $.ajax和 jQuery.ajax是等价的 $符号是jQuery的一个简写形式 window ...
- ping 计算机全名,返回的不是IP地址
今天想看一下机子的IP地址,结果关闭局域防火墙后,在命令行中使用ping 计算机全名,返回的不是IP地址 其实,这也是一种IP地址,IP6地址 原因:默认情况下,win7以上的操作系统,ping 计算 ...
- Listview性能优化
首先,虽然大家都知道,还是提一下,利用好 convertView 来重用 View,切忌每次 getView() 都新建.ListView 的核心原理就是重用 View.ListView 中有一个回收 ...
- Linux权限解释
从左至右,第一位数字代表文件所有者的权限,第二位数字代表同组用户的权限,第三位数字代表其他用户的权限. 而具体的权限是由数字来表示的,读取的权限等于4,用r表示:写入的权限等于2,用w表示:执行的权限 ...
- ios打开系统自带APP
打开系统自带app 打开系统设置: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root= ...
- Microsoft Visual Studio 2015 python 安装 mysql-python 出错解决
Microsoft Visual Studio 2015 安装 python 连接包 mysql-python出错 第一种 pip安装方式 安装Microsoft Visual C++ Compi ...
- 为什么需要异步?why?来看一段代码。
为什么需要异步?why?来看一段代码. 问题1: for(var i=0;i<100000;i++){ } alert('hello world!!!'); 这段代码的意思是执行100...次后 ...