diff --git a/tgyuuAn/README.md b/tgyuuAn/README.md index 714014d..d7020b6 100644 --- a/tgyuuAn/README.md +++ b/tgyuuAn/README.md @@ -90,4 +90,5 @@ | 86차시 | 2025.01.16 | 이분 탐색 | 통나무 자르기 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/265 | 87차시 | 2025.01.31 | 그리디 | 택배 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/268 | 88차시 | 2025.02.04 | DFS + DP | 내리막 길 | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/269 +| 89차시 | 2025.02.11 | 그리디 | | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/272 --- diff --git "a/tgyuuAn/\352\267\270\353\246\254\353\224\224/\355\225\251.py" "b/tgyuuAn/\352\267\270\353\246\254\353\224\224/\355\225\251.py" new file mode 100644 index 0000000..678216e --- /dev/null +++ "b/tgyuuAn/\352\267\270\353\246\254\353\224\224/\355\225\251.py" @@ -0,0 +1,41 @@ +import sys +from collections import defaultdict + +def input(): return sys.stdin.readline().rstrip() + +N = int(input()) +strings = list() +board = defaultdict(int) +can_not_be_zero = set() + +for _ in range(N): + string = input() + strings.append(string) + can_not_be_zero.add(string[0]) + + for idx, string in enumerate(string[-1::-1]): + board[string] += 10**(idx) + +answer = defaultdict(int) + +is_zero = "" +if len(board) >= 10: + for (key, value) in sorted(list(board.items()), key = lambda x : x[1]): + if key in can_not_be_zero: continue + + is_zero = key + answer[key] = "0" + break + +now = 9 +for (key, value) in sorted(list(board.items()), key = lambda x : x[1], reverse = True): + if key == is_zero: continue + + answer[key] = str(now) + now -= 1 + +accum = 0 +for string in strings: + accum += int("".join(map(lambda x : answer[x], string))) + +print(accum) \ No newline at end of file