from itertools import permutations
from collections import defaultdict
N = int(input())
alphabet = set()
total = defaultdict(int)
for _ in range(N):
temp = list(input())
alphabet.update(temp)
temp.reverse()
num = 1
for k in temp:
total[k] += num
num*= 10
result = 0
alphabet = list(alphabet)
num_list = list(range(10-len(alphabet),10))
for new_nums in permutations(num_list):
temp = 0
ind = 0
for key in total.keys():
temp += total[key]*new_nums[ind]
ind += 1
result = max(result,temp)
print(result)
from itertools import permutations
from collections import defaultdict
N = int(input())
alphabet = set()
total = defaultdict(int)
for _ in range(N):
temp = list(input())
alphabet.update(temp)
temp.reverse()
num = 1
for k in temp:
total[k] += num
num*= 10
result = 0
list_of_alpha = list(total.values())
num = 9
list_of_alpha.sort(reverse=True)
for k in list_of_alpha:
result = result + k*num
num -= 1
print(result)
'알고리즘 > 백준_복기_미완료' 카테고리의 다른 글
[BOJ/백준] 1722 순열의 순서 (0) | 2021.05.02 |
---|---|
[BOJ/백준] 1405 미친 로봇 (0) | 2021.05.02 |
[BOJ/백준] 1219 오민식의 고민 (0) | 2021.05.02 |
[BOJ/백준] 1202 보석 도둑 (0) | 2021.05.02 |
[BOJ/백준] 1188 음식 평론가 (0) | 2021.05.02 |