#P11447. 「ALFR Round 3」C 割

    ID: 10884 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>字符串贪心洛谷原创O2优化鸽笼原理洛谷月赛

「ALFR Round 3」C 割

Description

Let f(S)f(S) denote the lexicographically largest subsequence of the string SS. Given an integer kk, you need to divide the original string SS into kk substrings, where the ii-th substring is denoted as aia_i. The weight of a partition scheme is defined as maxf(ai)\max f(a_i) for 1ik1 \leq i \leq k. Since there are many partition schemes, you are required to find the lexicographically smallest weight among all possible partition schemes.

Note: The term "weight" here refers to a string.

Definition of Subsequence: A subsequence of a sequence is formed by removing some elements from the original sequence without changing the relative positions of the remaining elements.

Definition of Lexicographical Order: In lexicographical order, two strings are compared starting from the first character. If the characters differ, the string with the smaller first character is smaller. If the characters are the same, the comparison continues with the next character, and so forth, until all characters are compared. If one string is a prefix of another, the shorter string is considered smaller.

Input Format

The input consists of two lines.

The first line contains two integers nn and kk, where nn is the length of the string SS, and kk is the number of segments you need to divide the string into.

The second line contains a string SS.

Output Format

Output a string that represents the lexicographically smallest weight among all partition schemes.

7 2
skyaqua
y

Hint

In the sample, you can divide the string SS into sky and aqua as the 22 substrings. The functions ff for these strings are y and ua, respectively; thus, the maximum of ff values is y. It can be proven that y is the lexicographically smallest weight among all partition schemes.

Subtask Score Constraints
11 1010 n10n \leq 10
22 2020 n102n \leq 10^2
33 n3×102n \leq 3 \times 10^2
44 1010 All characters in the string SS are guaranteed to be equal
55 k=1k=1
66 3030 -
77 00 Extra hack tests

For all the tests, 1kn2×1051 \leq k \leq n \leq 2 \times 10^5, and the characters in the string SS are all lowercase letters.