반응형
def make_score(N, word):
score = {}
for i in range(N):
for j, e in enumerate(word[i]):
s = 10**(len(word[i])-j-1)
if not e in score:
score[e] = s
else:
score[e] += s
return score
def cal_max(score):
sorted_score = sorted(list(score.values()), reverse=True)
result = 0
for i , e in enumerate(sorted_score):
result += (9-i)*e
return result
if __name__ == '__main__':
N = int(input())
word = [list(map(str,input())) for _ in range(N)]
score = make_score(N, word)
print(cal_max(score))
반응형