CF118C Fancy Number
Description
A car number in Berland consists of exactly $ n $ digits. A number is called beautiful if it has at least $ k $ equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of $ n $ digits Vasya has to pay the sum of money, equal to the absolute difference between the old digit and the new one.
Help Vasya: find the minimum sum of money he should pay to make the number of his car beautiful. You should also find the resulting beautiful number. If there are several such numbers, then print the lexicographically minimum one.
Input Format
The first line contains two space-separated integers $ n $ and $ k $ ( $ 2
Output Format
On the first line print the minimum sum of money Vasya needs to change the number. On the second line print the car's new number. If there are several solutions, print the lexicographically minimum one.
Explanation/Hint
In the first sample replacing the second digit with an "8" costs $ |9-8|=1 $ . Replacing the fifth digit with an "8" costs the same. Replacing the sixth digit costs $ |6-8|=2 $ . As a result, Vasya will pay $ 1+1+2=4 $ for a beautiful number "888188".
The lexicographical comparison of strings is performed by the < operator in modern programming languages. The string $ x $ is lexicographically smaller than the string $ y $ , if there exists such $ i $ ( $ 1