P14357 [CSP-J 2025] Forming Numbers
Description
Little R is learning string processing. Little X gives Little R a string $s$, where $s$ contains only lowercase English letters and digits, and **contains at least one digit among $1 \sim 9$**. Little X wants Little R to use any number of the digits in $s$, in any order, to form a positive integer. **Note: Little R may choose identical digits in $s$, but each digit can be used only once.** For example, if $s$ is $\tt 1a01b$, then Little R may choose the $1$-st, $3$-rd and $4$-th characters at the same time, which are $1, 0, 1$, and form the positive integer $101$ or $110$; however, Little R cannot form the positive integer $111$, because $s$ contains only two digits $1$. Little R wants to know, among all the positive integers he can form, which one is the largest. You need to help Little R find the maximum positive integer he can form.
Input Format
The first line of input contains a string $s$, representing the string Little X gives to Little R.
Output Format
Output one positive integer on a single line, representing the maximum positive integer Little R can form.
Explanation/Hint
### Example 2 Explanation
$s$ contains the digits $2, 9, 0, 1, 0$. It can be proven that the maximum positive integer Little R can form is $92100$.
### Example 3
See $\textbf{\textit{number/number3.in}}$ and $\textbf{\textit{number/number3.ans}}$ in the contestant directory. This example satisfies the constraints of test points $9 \sim 11$.
### Example 4
See $\textbf{\textit{number/number4.in}}$ and $\textbf{\textit{number/number4.ans}}$ in the contestant directory. This example satisfies the constraints of test point $20$.
### Constraints
Let $|s|$ be the length of the string $s$. For all test data, it is guaranteed that:
- $1 \leq |s| \leq 10^6$;
- $s$ contains only lowercase English letters and digits, and contains at least one digit among $1 \sim 9$.
::cute-table{tuack}
| Test point | $\lvert s\rvert \leq$ | Special property |
| :--: | :--: | :--: |
| $1$ | $1$ | A |
| $2$ | $2$ | ^ |
| $3$ | ^ | None |
| $4$ | $10$ | A |
| $5,6$ | ^ | None |
| $7,8$ | $10^2$ | A |
| $9 \sim 11$ | ^ | None |
| $12$ | $10^3$ | A |
| $13,14$ | ^ | None |
| $15$ | $10^5$ | A |
| $16,17$ | ^ | B |
| $18,19$ | ^ | None |
| $20$ | $10^6$ | A |
| $21,22$ | ^ | B |
| $23 \sim 25$ | ^ | None |
- Special property A: $s$ contains only digits.
- Special property B: $s$ contains at most $10^3$ digits.
Translated by QwenWork