as the modified string, then the cost of modification is. ∣. Minimize the cost and output a lexicographically smallest
There is a digit string s s of length n n. Define f(x) f(x) be the number of times digit x x appears in the string s s. You can arbitrarily modify each character of s s into any digit so that the maximum value of f(x) f(x) is less than or equal to m m. Define s' s ′ as the modified string, then the cost of modification is sum_{i=1}^{n}{|s_i-s'_{i}|} ∑ i=1 n ∣s i −s i ′ ∣. Minimize the cost and output a lexicographically smallest s' s ′ . A digit string only contains characters from 0 to 9 9.