The Best Greeting
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian. In case of any discrepancy, the Ukrainian version is authoritative.
Zenyk prepared a surprise for Marichka. He made a wonderful postcard with his own hands and decided to write the best greeting. And at this stage, Zenyk’s imagination ran out. So he found a greeting on the Internet and wrote it down.
Then Zenyk looked at his gift and realized that this would not impress Marichka. Therefore, he decided to cut out several letters and paste these same letters back in their place, but in a different order. However, so that Marichka does not notice this, Zenyk can cut out at most \(k\) letters.
And Zenyk cannot just paste the letters back in any way. For some reason, he decided that Marichka would really like the greeting if it is lexicographically minimal among all possible greetings he can obtain. Help him find this greeting.
A string \(s\) is considered lexicographically smaller than a string \(t\) if there exists such an index \(i\) that \(s_1 = t_1\), \(s_2 = t_2\), …, \(s_{i-1} = t_{i-1}\) and \(s_i < t_i\), or \(s\) is a prefix of \(t\).
Input
The first line contains two integers \(n\) and \(k\) — the number of letters in Zenyk’s greeting and the number of letters Zenyk can choose, respectively.
The next line contains Zenyk’s greeting, which he downloaded from the Internet. The greeting consists only of lowercase Latin letters.
Output
In a single line, print the lexicographically minimal greeting that Zenyk can obtain.
Constraints
\(1 \le k \le n \le 10^5\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 7 3 acbdaxa | aabcaxd |
Notes
In the message acbdaxa, Zenyk can choose the letters at
indices 2, 4, and 7. By cutting them out and pasting them back in a
different order, he can obtain aabcaxd. This will be the
lexicographically smallest greeting.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|