# 1339-단어수학

> <https://www.acmicpc.net/problem/1339>

1. 각 알파벳이 자리수마다 몇개가 있는지 자료를 만듦
   * Ex) \[(A, 100100), (B, 10111), (C, 101)]
2. 자료를 값의 2번째항 기준으로 내림차순 정렬
3. 첫째 값부터 9, 8, 7,,, 곱해가며 더해주면 된다.

```python
import sys

n = int(input())
# 모든 알파벳을 유니코드 순 숫자로 바꿔준다.
lst = [list(map(lambda x: ord(x)-65, sys.stdin.readline().rstrip())) for _ in range(n)]
# 알파벳 개수의 리스트를 만들어주고
alph = [0 for _ in range(26)]

# 각 알파벳의 자리수만큼 알파벳마다 더해준다.
for info in lst:
    for i in range(len(info)):
        alph[info[-1-i]] += 10**i

alph.sort(reverse=True)

rst = 0
i = 9

for info in alph:
    if info:
        rst += info*i
        i -= 1

print(rst)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pyohamen.gitbook.io/til/algorithm/boj/1339.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
