#T190. 最长上升子序列

最长上升子序列

Description

A sequence of numbers bib_i is called increasing when b1<b2<...<bSb_1 < b_2 < ... < b_S. For a given sequence (a1,a2,...,aN)(a_1, a_2, ..., a_N), we can obtain some increasing subsequences (ai1,ai2,...,aiK)(a_{i1}, a_{i2}, ..., a_{iK}), where 1i1<i2<...<iKN1 \leq i_1 < i_2 < ... < i_K \leq N. Your task is to find the length of the longest increasing subsequence for the given sequence.

Input Format

The first line of input is the length of the sequence, NN (1N10001 \leq N \leq 1000).
The second line contains NN integers of the sequence, where each integer ranges from 00 to 1000010000.

Output Format

The length of the longest increasing subsequence.

7
1 7 3 5 9 4 8


4