Longest Increasing Subsequence


Longest Increasing Subsequence

Given an array of integer numbers x1,x2,…,xnx_1, x_2, \dots, x_n, what is the length of the longest (strictly) increasing subsequence? Subsequence.

(Yes i'm lazy i wrote this problem statement 11.46 last night.)

Input

The first line contains an integer nn. The second line contains nn integers, the values of the array.

Output

The length of the longest strictly increasing subsequence.

(If you've solved this problem before, try with a Segment Tree. I think its pretty intuitive :)

Constraints
  • 1≤n≤1051 \le n \le 10^5
  • ~-10^9 \le x_i \le 10^9

Example 1

Input 1
5
-2 0 10 -10 -7 
Output 1
3

Example 2

Input 2
10
-3 3 -2 0 3 4 9 3 -2 7 
Output 2
6

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.