Longest Increasing Subsequence
View as PDF
Submit solution
Points:
100
Time limit:
1.0s
PyPy 3
3.0s
Python 3
3.0s
Memory limit:
500M
Problem type
You are given a sequence of integers. A subsequence is formed by deleting zero or more elements without changing the order of the remaining elements.
Find the length of the longest subsequence whose values are strictly increasing.
Input
The first line contains an integer , the length of the sequence.
The second line contains integers:
.
Output
Print one integer: the length of the longest strictly increasing subsequence.
Constraints
Example 1
Input
8
10 9 2 5 3 7 101 18
Output
4
Explanation
One longest increasing subsequence is .
Example 2
Input
5
5 4 3 2 1
Output
1
Example 3
Input
6
2 2 2 2 2 2
Output
1
Comments