~/algor $ cat problems/dp-eng-uzun-osuvchi-qism-ketma-ketlik
Longest increasing subsequence
Hard
1000 ms
128 MB
67%
A positive integer $n$ and $n$ integers $a_{1}, a_{2}, \dots, a_{n}$ are given. Choose some of them without changing their order (not necessarily consecutive) so that the chosen ones are strictly increasing. Find the largest number of numbers that can be chosen.
Input
The first line contains a positive integer $n$. The second line contains $n$ space-separated integers $a_{i}$.
Output
One integer — the length of the longest strictly increasing subsequence.
Note
$1 \le n \le 2 * 10^{5}$
$-10^{9} \le a_{i} \le 10^{9}$
Examples
Input #1
8 10 9 2 5 3 7 101 18
Output #1
4
Input #2
4 4 4 4 4
Output #2
1