오랜만에...
처음엔 리스트로 저장하면서 했다가 그럴 필요가 없어서..
ans = 0
value = 9
alphabet = [0] * 26
for i in range(int(input())):
bias = 0
for j in input()[::-1]:
alphabet[ord(j) - 65] += 10 ** bias
bias += 1
alphabet.sort(reverse=True)
for i in range(26):
if alphabet[i] == 0:
break
ans += value * alphabet[i]
value -= 1
print(ans)
'Algorithm > Greedy' 카테고리의 다른 글
[백준] 2231번 분해합 (0) | 2021.02.04 |
---|---|
[백준] 1541번 잃어버린 괄호 (0) | 2021.01.24 |
[백준] 11501번 주식 (0) | 2021.01.14 |
[백준] 2812번 크게 만들기 (0) | 2020.11.28 |
[백준] 11508번 2+1 세일 (0) | 2020.10.20 |
댓글