#K77917. Largest Number Concatenation
Largest Number Concatenation
Largest Number Concatenation
You are given a list of non-negative integers. Your task is to arrange them such that they form the largest possible number when concatenated.
Formally, given a sequence of numbers \(a_1, a_2, \dots, a_n\), find a permutation \(\pi\) such that the concatenated string \[ result = a_{\pi(1)}a_{\pi(2)}\cdots a_{\pi(n)} \] is maximized in the lexicographical order.
Note: If the resulting number has leading zeros (e.g. when all input numbers are 0), the output should be simply "0".
inputFormat
The input is provided via standard input (stdin) and consists of two lines:
- The first line contains an integer \(n\) which represents the number of integers.
- The second line contains \(n\) non-negative integers separated by spaces.
outputFormat
Output a single line to standard output (stdout) representing the largest number that can be formed by concatenating the input numbers.
## sample5
3 30 34 5 9
9534330