시리얼 번호

last update: 2021.09.08.WED

1431 시리얼 번호, Silver 3

Memory 29200KB, Time 72ms


n = int(input())
nums = list([input().strip() for _ in range(n)])

def sum_num(num):
    sum_num = 0
    for i in range(len(num)):
        if num[i].isdigit():
            sum_num += int(num[i])
    return sum_num

result = sorted(nums, key = lambda x: (len(x), sum_num(x), x))

print('\n'.join(result))