run2ai / algorithm-taek

0 stars 0 forks source link

내림차순으로 자릿수 정렬하기 #18

Closed Blzae97 closed 1 month ago

Blzae97 commented 1 month ago

시간 제한: 2초 난이도: 실버V 백준 온라인 저지: 1427번 https://www.acmicpc.net/problem/1427

teang1995 commented 1 month ago
# https://www.acmicpc.net/problem/1427

import sys
from collections import defaultdict

N = sys.stdin.readline()[:-1]

num_dict = defaultdict(int)

for num in list(N):
    num_dict[int(num)] += 1

ans = ''
for num in reversed(range(10)):
    ans += str(num) * num_dict[num]

print(ans)