#T782. 大合照
大合照
Description
The COIers of CodesOnline are about to take a group photo!
"How should we arrange the order?"
"By user ID?"
"Or by each user's height?"
"Let’s base it on user IDs then. But instead of simply sorting by ID size, we should arrange them so that the integer formed by concatenating these IDs together is the smallest possible."
Input Format
There are multiple test cases.
For each test case:
- The first line contains a positive integer
n(less than or equal to 10,000), representing the number of members. - The second line contains
npositive integers (each less than or equal to 10,000,000), representing the IDs of the members. Note that IDs may be duplicated.
Output Format
For each test case, output a single positive integer, which is the smallest possible integer formed by concatenating all the member IDs.
7
14 36 154 58 36 3 8
9
5534 5226 5636 99956 30 135 35 8 77
1415433636588
135303552265534563677899956
Source
CodesOnline