Problem8575--DPL_1_D : Longest Increasing Subsequence

8575: DPL_1_D : Longest Increasing Subsequence

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

For a given sequence $A=a_0,a_1,…,a_{n−1}$, find the length of the longest increasing subsequnece (LIS) in $A$.

An increasing subsequence of $A$ is defined by a subsequence $a_{i_0},a_{i_1},…,a_{i_k}$ where $0≤i_0<i_1<…<i_k<n$ and $a_{i_0}<a_{i_1}<…<a_{i_k}$.

Input

$n$

$a_0$

$a_1$

$:$

$a_{n−1}$

In the first line, an integer $n$ is given. 

In the next $n$ lines, elements of $A$ are given.

Output

The length of the longest increasing subsequence of $A$.

Constraints

$1 ≤ n ≤ 100,000$
$0 ≤ a_i ≤ 10^9$

Sample 1 Input

5
5
1
3
2
4

Sample 1 Output

3

Sample 2 Input

3
1
1
1

Sample 2 Output

1

HINT

相同题目:DPL_1_D

Source/Category