programming max map

                                                 max map

There are n strings, each consisting of uppercase characters of AJ. Now you map each character to a number from 0-9, with different characters mapped to different numbers. This way each string can be treated as an integer, the only requirement is that the integers must be positive integers and their strings must not have leading zeros. Now how do you map characters to maximize the sum of the integers represented by these strings?

Enter description:

Each set of test cases contains only one set of data, the first line of each set of data is a positive integer n, followed by n lines, each line has a length of no more than 12 and only contains uppercase letters

AJ's string. n is not greater than 50, and there is at least one character that is not the first letter of any string.

Output description:
 
 

Output a number indicating what the maximum sum is.

Example 1

enter

2
ABC
BCA

output

1875




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325492788&siteId=291194637