Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@
| 86μ°¨μ‹œ | 2025.01.16 | 이뢄 탐색 | <a href="https://www.acmicpc.net/problem/1114">ν†΅λ‚˜λ¬΄ 자λ₯΄κΈ°</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/265
| 87μ°¨μ‹œ | 2025.01.31 | 그리디 | <a href="https://www.acmicpc.net/problem/8980">택배</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/268
| 88μ°¨μ‹œ | 2025.02.04 | DFS + DP | <a href="https://www.acmicpc.net/problem/1520">내리막 κΈΈ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/269
| 89μ°¨μ‹œ | 2025.02.11 | 그리디 | <a href="https://www.acmicpc.net/problem/1132">ν•©</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/272
---
41 changes: 41 additions & 0 deletions tgyuuAn/그리디/ν•©.py
Original file line number Diff line number Diff line change
@@ -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)