#P6095. [JSOI2015] 串分割

    ID: 5075 远端评测题 3000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2015二分各省省选江苏后缀数组,SA

[JSOI2015] 串分割

Description

JYY wrote a circular string SS of length NN that contains only the 99 different characters 1, 2, \ldots, 9. JYY wants to cut SS exactly KK times, splitting it into KK non-empty substrings. For each substring, since it contains only digits, we can treat it as a decimal number. Therefore, after KK cuts, JYY can obtain KK different decimal numbers. JYY wants the largest among these KK numbers to be as small as possible.

Input Format

The first line contains two integers NN and KK.

The second line contains a string SS of length NN.

Output Format

Output one line containing a positive integer, which is the minimum possible value of the largest number among the KK numbers obtained in an optimal splitting plan.

4 2
4321
32

Hint

For 100%100\% of the testdata, 3N2×1053\leq N\leq 2\times 10^5, 2KN2\leq K\leq N.

Translated by ChatGPT 5