지나가던 개발자

[Python] 백준 5635번(생일) 문제 풀이 본문

PS/Python

[Python] 백준 5635번(생일) 문제 풀이

KwonYongHyeon 2022. 11. 15. 17:00

 

from datetime import datetime

youngest = ["", datetime.strptime("1990 01 01", "%Y %m %d")]
oldest = ["", datetime.strptime("2010 12 31", "%Y %m %d")]

for i in range(int(input())):
    nameAndBirth = input()
    name = nameAndBirth.split()[0]
    birth = datetime.strptime(" ".join(nameAndBirth.split()[1:]), "%d %m %Y")
    if birth <= oldest[1]:
        oldest[0] = name
        oldest[1] = birth
    if birth >= youngest[1]:
        youngest[0] = name
        youngest[1] = birth
        
print(youngest[0])
print(oldest[0])
Comments