Best name(translated by:LydiaCCC)

Best name(translated by:LydiaCCC)

Bessie, one of Farmer John (FJ) ‘s cow, has given birth to a calf, who FJ decides to name to show his gratitude to Bessie.
FJ is an American, so there are only lowercase letters in the name. Besides, he intends to name the calf with a word of a fixed length of N .
Also, FJ plans to make the name incredibly unique so each letter in the name appears only once.
As a mother, Bessie is concerned about the name of the baby. She gave each letter a different score and she thinks the score of a name is the sum of each letter involved in it.
Given N and Bessie's rating scale, please find out all the names winning the highest score.
Given 27 lines, the first line is an integer N. There is each an integer xi in the following 26 lines, which represents Bessie's grade for a, b, c, d..., z. 1 < = N < = 8, 1 < = xi < = 100.
Output all the names which win the highest score. And should be only one word in each line. followed by a carriage return . Attention, the output should be in dictionary order: that is to say, if all the names are sorted in ascending order, your output order should be the same as the sorted one.
To compose it neatly, the sample input puts all the numbers in one line. Actually, there is only one integer in each line, followed by no blank spaces.

Sample 1
Input:

1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Output:

z

Sample 2
Input:

3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

Output:

xyz
xzy
yxz
yzx
zxy
zyx

The answer will be false if the output order is not a dictionary order, even though all the schemes are correct.


Special thanks: this is translated selflessly by LydiaCCC, who did not want to be named.

信息

难度
9
分类
(无)
标签
递交数
2
已通过
1
通过率
50%
上传者