POJ2533(KB12-N LIS)
Longest Ordered Subsequence
| Time Limit: 2000MS | Memory Limit: 65536K | |
| Total Submissions: 50827 | Accepted: 22574 |
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
Source
//2017-04-04
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; const int N = ;
int dp[N], a[N];//dp[i]表示前i个数字的最长上升子序列 int main()
{
int n;
while(cin>>n)
{
for(int i = ; i < n; i++)
cin>>a[i];
int mx = ;
for(int i = ; i < n; i++){
dp[i] = ;
for(int j = ; j < i; j++){
if(a[j] < a[i])
dp[i] = max(dp[i], dp[j]+);
}
mx = max(mx, dp[i]);
}
cout<<mx<<endl;
} return ;
}
POJ2533(KB12-N LIS)的更多相关文章
- 【动态规划+二分查找】POJ2533&POJ1631最长上升子序列(LIS)
POJ2533裸的LIS,时间复杂度为O(n^2) #include<iostream> #include<cstdio> using namespace std; +; in ...
- DP总结 ——QPH
常见优化 单调队列 形式 dp[i]=min{f(k)} dp[i]=max{f(k)} 要求 f(k)是关于k的函数 k的范围和i有关 转移方法 维护一个单调递增(减)的队列,可以在两头弹出元素,一 ...
- poj2533 LIS
题目链接: http://poj.org/problem?id=2533 题意:第一个数n,接下来n个数,> ....求最长上升子序列. 这道题有两种解法,第一种是通解,也适用于别的LIS. ...
- POJ2533:Longest Ordered Subsequence(LIS)
Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence ...
- POJ-2533.Longest Ordered Subsequence (LIS模版题)
本题大意:和LIS一样 本题思路:用dp[ i ]保存前 i 个数中的最长递增序列的长度,则可以得出状态转移方程dp[ i ] = max(dp[ j ] + 1)(j < i) 参考代码: # ...
- (线性DP LIS)POJ2533 Longest Ordered Subsequence
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 66763 Acc ...
- POJ2533 Longest Ordered Subsequence —— DP 最长上升子序列(LIS)
题目链接:http://poj.org/problem?id=2533 Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 6 ...
- 最长上升子序列算法(n^2 及 nlogn) (LIS) POJ2533Longest Ordered Subsequence
问题描述: 一个数的序列bi,当b1 < b2 < ... < bS的时候,我们称这个序列是上升的.对于给定的一个序列(a1, a2, ..., aN),我们可以得到一些上升的子序列 ...
- Lis日常维护
1.[问题]护士站打印LIs条码,出来是PDF格式的 [解决]在文件夹Client\NeusoftLis\Xml\Print.xml中把BarcodePrint Name的值改成安装的斑马打印机名(不 ...
随机推荐
- JQuery的页面操作
window.location = "http://www.xxxxxxxx.net" 跳转后有后退功能 其实应该是 window.location.hrefwindow.loca ...
- [学习笔记]min_25筛
神佬yyb 神佬zsy 想不到花了两个小时的时间看 \(min\_25\) 筛就看懂了 实际去追了一下魔禁3 我们先举个例子.如求 \[\sum_{i=1}^{n}f(i)\] 其中 \(f(i)\) ...
- Java - Tips
001 - Java中print.printf与println的区别? printf:格式化输出,用来控制输出的格式. print:标准输出,不换行. println:标准输出,换行.例如,print ...
- postgresql-查看表大小
drop table tablesize create table tablesize( phone int) create table tablesize( phone text) create t ...
- W,b的初始化和几种激活函数
权重W不能全部初始化为0,原因很简单,我们可以自己在本子上推导一下,假设现有一个含有一个隐藏层,隐藏层含有两个神经元初始输入为两个向量的网络,如果权重初始化全部为0,那么,第一层的输出,会和第二层的输 ...
- vue教程2-06 过滤器
vue教程2-06 过滤器 过滤器: vue提供过滤器: capitalize uppercase currency.... <div id="box"> {{msg| ...
- (转)深入浅出 RPC - 深入篇
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/mindfloating/article/details/39474123 <深入篇>我们 ...
- C#:自定义函数
将数组转成字符串 /// <summary> /// 将数组转成字符串 /// </summary> /// <param name="glue"&g ...
- ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context
封装Redis发布订阅时,SUB时,又想探测具体Channel的状态,于是执行PUBSUB CHNNALES命令,报 ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / ...
- Mac 下配置 Python 开发环境
➜ ~ sudo brew install python3 ==> Downloading https://www.python.org/ftp/python/3.5.1/Python-3.5. ...