最长有序子序列
目录
AC1解题思路:写了个for循环来判断某个数字和它前面的数字的大小情况。利用一个数组定义所有的数字本来是最长有序子列长度为1,如果是小于这个数的话,记录++;然后再先一个循环求出最长的那个
AC2解题思路:然后定义状态dp[i](代表以第i个数为结尾的最长递增子序列的长度,也表示有多少个递减子序列,及dp[i]=max{0,dp[j]+1},0
A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (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 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.
当给定数字序列时,您的程序必须找到其