Number
Time limit2sMemory limit1024 MB
Given several digit strings (the pieces), arrange all of them in some order to form the largest possible number and print it.
- Level
Medium5 of 10
- Topics
- String, Sorting, Greedy, Implementation
- Solved
- No attempts yet
Problem
Vasya wrote a large number on a long strip of paper and decided to boast about it to his older brother Petya. But as soon as he left the room to call his brother, his sister Katya ran into the room and cut the strip of paper into several pieces. As a result, each piece held one or more consecutive digits.
Now Vasya cannot remember which number he wrote. He only remembers that it was very large. To comfort his younger brother, Petya decided to determine the largest number that could have been written on the strip before it was cut. Help him!
Input
The input file contains one or more lines, each of which holds a sequence of digits. The number of lines in the input file does not exceed 100, and each line contains from 1 to 100 digits. It is guaranteed that in at least one line the first digit is not zero.
Output
Print one line to the output file: the largest number that could have been written on the strip before it was cut.