[백준] 5635번 생일

거북이·2023년 1월 4일
0

백준[실버5]

목록 보기
48/114
post-thumbnail

💡문제접근

연도를 기준으로 1차 정렬, 월을 기준으로 2차 정렬, 일을 기준으로 3차 정렬을 하면 맨 처음 나오는 요소는 가장 나이가 많은 사람이 되고 맨 마지막에 나오는 요소는 가장 나이가 적은 사람이 된다.

💡코드(메모리 : 30616KB, 시간 : 32ms)

import sys

n = int(input())
student = []
for _ in range(n):
    name, day, month, year = map(str, sys.stdin.readline().strip().split())
    day = int(day)
    month = int(month)
    year = int(year)
    student.append([name, day, month, year])
student.sort(key = lambda x : (x[3], x[2], x[1]))

print(student[n-1][0])
print(student[0][0])

💡소요시간 : 4m

0개의 댓글