Processing math: 100%
Longest increasing subsequence - MarisaOJ: Marisa Online Judge

Longest increasing subsequence

Time limit: 1000 ms
Memory limit: 256 MB
You are given an array A of n integers, find the longest increasing subsequence (LIS) of A. In other words, find the largest k that there exist k indices i1<i2<...<ik that Ai1<Ai2<...<Aik. ### Input - The first line contains an integer n. - The second line contains n integer Ai. ### Output - Print the length of the LIS. ### Constraints - 1≤n≤1000 - 1≤Ai≤109. ### Example Input: 537218 Output: 3 #### Note: The LIS is (3,7,8).