#C5030. Largest Concatenated Number
Largest Concatenated Number
Largest Concatenated Number
Given an array of non-negative integers, arrange them to form the largest possible concatenated number.
You are provided with N non-negative integers. You need to arrange them in such a way that when they are concatenated, they form the largest possible number. More formally, if two numbers are represented as strings x and y, you should order them so that the concatenation x+y is greater than y+x. This can be expressed using the following custom comparator in LaTeX format:
\( \text{cmp}(x,y) = \begin{cases} -1 & \text{if } x+y > y+x, \\ 1 & \text{if } x+y < y+x, \\ 0 & \text{otherwise.} \end{cases} \)
Note that if the resulting string has a leading zero, the answer should be just "0".
inputFormat
The input is read from stdin as follows:
- The first line contains a single integer N (1 ≤ N ≤ 104), the number of integers.
- The second line contains N non-negative integers separated by spaces.
outputFormat
Output to stdout a single string representing the largest possible concatenated number.
## sample2
10 2
210