#C1791. Largest Concatenated Number
Largest Concatenated Number
Largest Concatenated Number
Given a list of non-negative integers, your task is to arrange them such that they form the largest possible number when concatenated together.
For two numbers represented as strings (a) and (b), we define a custom ordering: compare (a+b) with (b+a). If (a+b > b+a) (in lexicographical order), then (a) should come before (b). Otherwise, (b) should come before (a).
For example, given the list [3, 30, 34, 5, 9], concatenating them in the order 9, 5, 34, 3, 30 yields 9534330, which is the largest possible combination.
inputFormat
Input is read from standard input. The first line contains an integer (n), denoting the number of elements. The second line contains (n) space-separated non-negative integers.
outputFormat
Output the largest concatenated number formed by ordering the given integers. The result should be printed to standard output.## sample
5
3 30 34 5 9
9534330