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 | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
9 | awoo | 152 |
10 | luogu_official | 151 |
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.