Longest Increasing Subsequence

MEDIUM-HARD · C · 3000ms

In the "longest streak" round, players are given a sequence of numbers and must find the longest strictly increasing streak they can pick out (not necessarily consecutive). Read N integers and print the length of the longest strictly increasing subsequence. Aim for O(N log N).

Input

Line1: N. Line2: N integers.

Output

Length of the LIS.

Constraints

1 ≤ N ≤ 10^5

Sample Input

6
10 9 2 5 3 7

Sample Output

3
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Longest Increasing Subsequence · DIU ContestHub