#C9320. Maximize Sequence
Maximize Sequence
Maximize Sequence
You are given an integer k and a sequence of characters of length k, which consists of digits ('0'–'9') and question marks ('?'). Your task is to replace every '?' in the string with a digit in such a way that the sum of the digits in the resulting sequence is maximized. In the case of a tie (if multiple sequences have the same maximum digit sum), you should output the lexicographically smallest result.
Note: Since replacing each '?' with '9' always maximizes the sum, the solution is to simply replace all '?' characters with '9'.
The input is provided via standard input and the output via standard output.
For example, if k = 3
and the sequence is 1?5
, the correct output is 195
.
inputFormat
The input consists of two lines:
- The first line contains an integer k which denotes the length of the sequence.
- The second line contains the sequence of characters (digits and/or '?').
You should read input from standard input (stdin).
outputFormat
Output the modified sequence after replacing every '?' with '9'. The output should be printed to standard output (stdout).
## sample3
1?5
195