ACM: 最长子序 dp题 poj 2533
来源:互联网 发布:深圳阿里云大厦 编辑:程序博客网 时间:2024/06/10 23:47
Description
A numeric sequence of aiis ordered if a1 <a2 < ... <aN. Let the subsequence of the given numericsequence (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 manyothers. 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 thelength of sequence N. The second line contains the elements ofsequence - N integers in the range from 0 to 10000 each, separatedby spaces. 1 <= N <= 1000
Output
Output file must contain a single integer -the length of the longest ordered subsequence of the givensequence.
Sample Input
7 1 7 3 5 9 4 8
Sample Output
4
题意:
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 1005
int n;
int a[MAX];
int dp[MAX];
inline int max(int a,int b)
{
}
int main()
{
//
}
- ACM: 最长子序 dp题 poj 2533
- ACM: 最长公共子序 poj 1458
- ACM: 回文串 dp题 poj 1159 (滚动…
- ACM: 最长升序和最长降序 dp题 poj…
- ACM: dp题 poj 1276 go on 动态规…
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题 --> 背包问题 poj 1837
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: 树状DP 动态规划题 poj 1463 …
- ACM: 动态规划题 poj 2057 树状DP
- POj 2379 ACM Rank Table
- ACM: DP训练好题 动态规划题 poj 1…
- ACM: 简单数塔题 dp题 poj 3176
- ACM: 最优解 dp题 poj 1260
- ACM: DP+floyd 动态规划题 poj 117…
- ACM: 概率DP 动态规划题 poj 1322
- ACM: 动态规划题 poj 1192 树形DP
- POj 1159 Palindrome (dp)
- ACM: 直接模拟题 poj 3087
- ACM: poj 3349 (学习hash多种方法.…
- ACM: 计算交换次数的排序题 poj 22…
- ACM: 模拟题 poj 2632 (开始做模拟…
- hdu_4714_Tree2cycle(树形DP)
- ACM: 最长子序 dp题 poj 2533
- ACM: 简单数塔题 dp题 poj 3176
- ACM: 最优解 dp题 poj 1260
- ACM: 最长升序和最长降序 dp题 poj…
- ACM: dp动态规划题(难) poj 3267 …
- ACM: dp题 poj 1276 go on 动态规…
- ACM: dp题 --> 背包问题 poj 1837
- ACM: dp题(动态规划) poj 2151 (d…
- ACM: hash题 poj 3274 (题目看了好…