#P13968. [VKOSHP 2024] Classics
[VKOSHP 2024] Classics
题目描述
You are probably familiar with the classic problem of finding the longest increasing subsequence in an array. Let be an array consisting of integers. A subsequence is called if . The longest increasing subsequence is the increasing subsequence of maximum length. Of course, we will not ask you to solve the classic problem; you will have to solve its more complicated version...
Initially, there is an empty array . Then, the numbers are added to the array in this order. The number is added to the array at position . Positions in the array are numbered with integers from to , where is the current size of the array. When adding an element at position in an array of size , all elements that previously had positions from to are shifted one position to the right, and the current element is added to the freed space.
Your task is to determine the length of the longest increasing subsequence in the array after each addition of a new element.
输入格式
The first line contains one integer () --- the number of added elements.
The second line contains integers () --- denotes the position where element is added.
输出格式
Output integers --- the length of the longest increasing subsequence of the array after each addition of a new element.
5
1 2 1 3 4
1
2
2
2
3
1
1
1
提示
The array in the first example changed as follows: $[] \to [1] \to [1, 2] \to [3, 1, 2] \to [3, 1, 4, 2] \to [3, 1, 4, 5, 2]$.