Maximal Subsequence
Time limit1sMemory limit256 MB
Given an array, find the longest subsequence whose LIS length is strictly smaller than the LIS length of the whole array.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Binary search, Graph
- Solved
- No attempts yet
Problem
Let the beauty of a sequence be the length of its longest increasing subsequence.
You are given an array consisting of integers. Find the maximum length of a subsequence of array such that the beauty of this subsequence is less than the beauty of the whole array .
Input
The first line contains a single integer , the number of elements in array ().
The second line contains space-separated integers ().
Output
Print one integer: the maximum length of a subsequence of array such that its beauty is less than the beauty of the whole array .