Make the Largest Number
InterviewTime limit2sMemory limit512 MB
Given up to 1000 non-negative integers, order the pieces so their concatenation is the largest possible number, and print it without leading zeros.
Problem
You are given a list of N non-negative integers. Write a program that finds the largest number that can be formed by arranging the numbers in the list.
Input
The first line gives the number of integers N (1 ≤ N ≤ 1,000). The second line gives the numbers in the list. The numbers are separated by spaces and are non-negative integers less than or equal to 1,000,000,000. Every number except 0 does not start with 0, and if 0 appears, it appears as a single 0.
Output
Print the largest number that can be formed by arranging the numbers in the list. The number must not start with 0, and if the answer is 0, you must print a single 0.