λ¬Έμ
https://www.acmicpc.net/problem/1339
νμ΄
n = int(input())
words = []
for _ in range(n):
words.append(list(map(lambda x: ord(x) - 65, input()))) # μνλ²³μ μ«μλ‘ λ°κΎΈμ΄ μΈλ±μ€λ‘ μΈ μ μλλ‘ ν¨
alphabets = [0] * 26 # κ° μνλ²³μ μλ¦Ώμ μ μ₯
for word in words:
for idx, char in enumerate(word[::-1]):
alphabets[char] += (10 ** idx) # μλ¦Ώμλ§νΌ λν΄μ£ΌκΈ°
alphabets.sort(reverse=True) # λ΄λ¦Όμ°¨μ μ λ ¬
sum_value = 0
num = 9
for i in range(9):
sum_value += num * alphabets[i]
num -= 1
print(sum_value)
'ποΈ Algorithm > π© λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
π© [λ°±μ€] [Python] [Silver3] 15903λ²_μΉ΄λ ν©μ²΄ λμ΄ (0) | 2023.05.29 |
---|---|
π© [λ°±μ€] [Python] [Silver3] 2346λ²_νμ ν°λ¨λ¦¬κΈ° (0) | 2023.05.29 |
π© [λ°±μ€] [Python] [Gold5] 13219λ²_Trains (0) | 2023.05.14 |
π© [λ°±μ€] [Python] [Gold2] 12015λ²_κ°μ₯ κΈ΄ μ¦κ°νλ λΆλΆ μμ΄ 2 (0) | 2023.05.12 |
π© [λ°±μ€] [Python] [Gold4] 1043λ²_κ±°μ§λ§ (0) | 2023.05.12 |