BOJ - 1431 - 시리얼 번호
Updated:
import sys
def isDigitCheck(number) :
answer = 0
for i in number :
if i >= '0' and i <= '9' :
answer += int(i)
return answer
def solution():
N = int(sys.stdin.readline())
number = []
for _ in range(N):
number.append(sys.stdin.readline().strip())
number = sorted(number, key=lambda x: (len(x), isDigitCheck(x), x))
for n in number:
print(n)
solution()
https://www.acmicpc.net/problem/1431
Leave a comment