Longest Increasing Subsequence 3
Time limit3sMemory limit512 MB
Given a sequence of up to 10^6 integers, find the length of the longest strictly increasing subsequence.
- Level
Medium5 of 10
- Topics
- Dynamic programming, Binary search
- Solved
- No attempts yet
Problem
Given a sequence , write a program that computes the length of its longest increasing subsequence.
A subsequence of is what you get by picking some elements of and keeping their original order. An increasing subsequence is one whose values grow from left to right, so the same value may not appear twice in it.
For example, if , then the longest increasing subsequence is and its length is .
Input
The first line contains the size of the sequence . ()
The second line contains the integers of the sequence , separated by spaces. ()
Output
Print the length of the longest increasing subsequence of on the first line.