Longest ascending subsequence Time Limit: 3000 Ms memory limit: 65536 k any questions? Click Here ^_^ This topic describes a number sequence Bi, when B 1 <B 2 <... <B S We call this sequence ascending. For a given sequence ( 1 , 2 ,..., N ), We can get some ascending subsequences ( I1 , I2 ,..., Ik ), Here 1 <= I1 <I 2 <... <I K <= N. For example, for a sequence (1, 7, 3, 5, 9, 4, 8), some of its ascending subsequences, such as (1, 7), (3, 4, 8. The longest length of these subsequences is 4, for example, subsequences (1, 3, 5, 8 ).
Your task is to find the length of the longest ascending subsequence for the given sequence. The first line of the input is the sequence length N (1 <= n <= 1000 ). The second row contains N integers in the sequence. The values of these integers range from 0 to 10000. The length of the output longest ascending subsequence. Sample Input
71 7 3 5 9 4 8
Sample output
4
The source is northeastern Europe 2002. Presumably this is a very classic DP question. I have been studying DP for several days. I have done a few questions with ignorance. Most of them are done in the report on solving problems, I think the only way to improve DP is to do more exercises-I will post it for each DP in the future. I 'd like to summarize the ideas for solving DP problems first, get a DP question first (at present, this scum cannot determine whether to use DP without being certain (will it be said again ..)) First, we need to break down a problem
Sub-questions So what are the sub-problems of this problem? The longest ascending subsequence of a series whose length is N is required .. n) the longest ascending subsequence of the ending series is a subproblem.
Status For each k value, it corresponds to a number (with a (k) as the end point, the longest ascending subsequence length). Assume that the value is DP [K ].
DP [k] = max {DP [I], 1 = <I <k, and a (I) <A (K) and k! = 1} + 1 (state transition equation)