How to find the lexographically smallest Longest Increasing Subsequence of a fixed length k.where size of the array is 100000 and 1<=k<=100000.
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
How to find the lexographically smallest Longest Increasing Subsequence of a fixed length k.where size of the array is 100000 and 1<=k<=100000.
Name |
---|
What does " Longest Increasing Subsequence of a fixed length $$$k$$$" mean?
I think he means LIS of a bunch of strings, each string of length k
What it sounds like to me is that he wants the lexicographically smallest increasing subsequence of length $$$k$$$ in the array (i.e. Take all the increasing subsequences of length $$$k$$$. Of them choose the lexicographically smallest), but I'm not sure, so I asked
Sorry for my bad English. you are right . I want the " lexicographically smallest increasing subsequence of length k in the array (i.e. Take all the increasing subsequences of length k. Of them choose the lexicographically smallest)"
You can modify the $$$O(N \cdot \log N)$$$ algorithm, run it from right to left and obtain for each $$$i$$$ the smallest value for which there exists an increasing sequence of length $$$i$$$, starting with that value. Consequently you can also obtain the length of the longest increasing sequence that starts at a given index.
Now for the construction, you want to take the smallest value that allows you to make an IS with that starting value. That is the minimum between the numbers where the max length is at least $$$k$$$. Next you want to remove all the values to the left of what you just picked up. You also want to add all the elements to the right of the first element, that have a max_length at least $$$k - 1$$$. Next you remove elements to the left, add new ones from the right, ...
I would suggest you try on a couple small examples, $$$[5, 6, 3, 4, 1, 2]$$$, $$$[1, 2, 3]$$$, $$$[4, 7, 2, 5, 3, 1, 6, 8]$$$.
If you don't understand something then just reply to this comment and I will do my best to explain
Thank you. got it.