CF910C Minimum Sum
题目描述
Petya 有一个长度为n的正整数序列 $a_{1},a_{2},...,a_{n}$。他的朋友Vasya 想要捉弄他,Vasya用一个字母替换了Petya 的号码中的所有数字。
他用小写字母‘a’到‘j’中的一个字母替换了所有数字 0,用另一个字母替换了所有 1,依次类推。对于不同的两个数字,Vasya 用‘a’到‘j’中不同的字母。
你的任务是还原 Petya 的序列。还原得到的数字应是没有前导零(数字开头没有零)的正整数。由于可能有多种方式实现,所以要求恢复后的序列总和最小。保证初始时序列中数字没有前导零。
输入格式
第一行包含一个数字n。
之后的每一行包含一个由小写字母‘a’到‘j’构成非空字符串,每个字符串长度不超过六个字符。
输出格式
恢复后的序列的和的最小值。保证有解。
Translated by Fowany
说明/提示
In the first example, you need to replace the letter 'a' with the digit $ 1 $ , the letter 'b' with the digit $ 0 $ , the letter 'd' with the digit $ 2 $ , the letter 'e' with the digit $ 3 $ , and the letter 'j' with the digit $ 4 $ . So after the restoration numbers will look like $ [10,23,14] $ . The sum of them is equal to $ 47 $ , which is the minimum possible sum of the numbers after the correct restoration.
In the second example the numbers after the restoration can look like: $ [120468,3579,2468,10024,3] $ .
In the second example the numbers after the restoration can look like: $ [11,22,11] $ .