#ABC471F. 拼接(最大化) / Concat (maximize)
拼接(最大化) / Concat (maximize)
题目描述
You are given strings consisting of digits.
Find the maximum possible value, when interpreted as a decimal integer (after removing extra leading zeros), of a string obtained by choosing exactly of these strings and concatenating them in any order of your choice.
Here, the value obtained by interpreting a string consisting entirely of the character 0 as a decimal integer after removing extra leading zeros is defined to be .
输入格式
The input is given from Standard Input in the following format:
输出格式
Output the answer.
数据范围
- is a string of length between and (inclusive) consisting of digits.
- and are integers.
3 2
123
45
6
45123
There are six strings obtained by choosing two of 123, 45, 6 and concatenating them: 12345, 1236, 45123, 456, 6123, 645.
Among these, the maximum value when interpreted as a decimal integer is .
5 3
00000
00
1
0000
000
1000000000
9 9
0000000001
000000002
00000003
0000004
000005
00006
0007
008
09
90080007000060000050000004000000030000000020000000001
The answer must be output without extra leading zeros.
相关
在下列比赛中: