bzoj#P3929. [SEERC2014] Circle of digits
[SEERC2014] Circle of digits
Description
You are given a circular string of length that consists of digits . You want to split it into continuous non-empty parts. Each of those parts represents a decimal notation of some integer number. Your goal is to find a partition that minimizes the maximum integer from the partition at hand.
For example, if the string is and then the optimal partition is which has as the maximum number. Note that the string is cyclic, that is the first character goes right after the last one (as in the part of the above example).
Input Format
The first line of the input contains two integers and .
The second line contains a string of length which consists only of characters .
Output Format
Output the value of the maximal number in the optimal partition.
4 2
4321
32
7 3
7654321
176
5 5
12321
3
Hint
In the first sample the optimal partition is .
In the second sample the optimal partition is .
In the third sample the optimal (and the only possible) partition is $\{\texttt 1,\texttt 2,\texttt 3,\texttt 2,\texttt 1\}$.
Limits
For of testcases, , .