SDUT_1299 最长上升子序列
2017-08-31 12:16
204 查看
最长上升子序列
Time Limit: 3000MS Memory Limit: 65536KBSubmit Statistic Discuss
Problem Description
一个数的序列bi,当b1 < b2 < ... < bS的时候,我们称这个序列是上升的。对于给定的一个序列(a1,a2, ..., aN),我们可以得到一些上升的子序列(ai1,
ai2, ..., aiK),这里1<= i1 <
i2 < ... < iK <= N。比如,对于序列(1, 7, 3,
5, 9, 4, 8),有它的一些上升子序列,如(1, 7), (3, 4, 8)等等。这些子序列中最长的长度是4,比如子序列(1, 3, 5, 8)。
你的任务,就是对于给定的序列,求出最长上升子序列的长度。
Input
输入的第一行是序列的长度N (1 <= N <= 1000)。第二行给出序列中的N个整数,这些整数的取值范围都在0到10000。
Output
最长上升子序列的长度。
Example Input
7 1 7 3 5 9 4 8
Example Output
4
#include <iostream> #include <algorithm> using namespace std; int main() { int array[1010],Max[1010]; int n; cin>>n; for(int i=0;i<n;++i) { cin>>array[i]; Max[i]=1; } for(int i=1;i<n;++i) for(int j=0;j<i;++j) if(array[i]>array[j]) Max[i]=max(Max[i],Max[j]+1); cout<<*max_element(Max,Max+n); return 0; }
相关文章推荐
- SDUT 1299----最长上升子序列
- sdut1299 最长上升子序列(动态规划)
- sdut 1299 最长上升子序列
- sdut 1299 最长上升子序列
- SDUT 1299 最长上升子序列
- sdut 1299最长上升子序列
- SDUT 1299 最长上升子序列
- sdut1299 最长上升子序列(dp入门)
- 1299最长上升子序列
- sdut.acm 2012级《程序设计基础Ⅱ)》_动态规划 最长上升子序列
- SDUTOJ 1299 最长上升子序列
- SDUt 2028 最长上升子序列
- 算法系列_实例01_最长上升子序列问题
- 返回最长上升子序列
- NYOJ17(最长上升子序列)
- 动态规划-最长上升子序列
- [TJOI2013]最长上升子序列
- 最长公共上升子序列
- DP经典应用(四)二维最长上升子序列问题——矩形嵌套问题
- 最长上升子序列 变异版 题解