백준 1431 시리얼 번호

김민영·2023년 1월 16일
0

알고리즘

목록 보기
74/125

과정

  • 정렬하려는 기준에 맞게 리스트에 추가해서 sort로 정렬했다.
import sys
input = sys.stdin.readline

N = int(input())
lst = []
for i in range(N):
    inp = input().rstrip()
    sum = 0
    for num in inp:
        if num.isnumeric():
            sum += int(num)
    lst.append([len(inp), sum, inp])
lst.sort(key=lambda x : (x[0], x[1], x[2]))
for i in lst:
    print(i[2])
  • sys.stdin.readline 사용한 것과 사용하지 않은 것의 시간차
  • sort를 사용하지 않고 정렬하는 방법을 공부해야겠다.
profile
노션에 1차 정리합니당 - https://cream-efraasia-f3c.notion.site/4fb02c0dc82e48358e67c61b7ce8ab36?v=

0개의 댓글