μ•Œκ³ λ¦¬μ¦˜ 문제/BOJ_Python

[BOJ/Step12] 11814 : λ‚˜μ΄μˆœ μ •λ ¬ (Python)

NaNaRinπŸ™ƒ 2021. 2. 19. 17:41

www.acmicpc.net/problem/10814

 

10814번: λ‚˜μ΄μˆœ μ •λ ¬

온라인 저지에 κ°€μž…ν•œ μ‚¬λžŒλ“€μ˜ λ‚˜μ΄μ™€ 이름이 κ°€μž…ν•œ μˆœμ„œλŒ€λ‘œ 주어진닀. μ΄λ•Œ, νšŒμ›λ“€μ„ λ‚˜μ΄κ°€ μ¦κ°€ν•˜λŠ” 순으둜, λ‚˜μ΄κ°€ κ°™μœΌλ©΄ λ¨Όμ € κ°€μž…ν•œ μ‚¬λžŒμ΄ μ•žμ— μ˜€λŠ” μˆœμ„œλ‘œ μ •λ ¬ν•˜λŠ” ν”„λ‘œκ·Έλž¨μ„

www.acmicpc.net


νšŒμ›μ„ λ‚˜μ΄κ°€ μ¦κ°€ν•˜λŠ” 순으둜, λ‚˜μ΄κ°€ κ°™λ‹€λ©΄ λ¨Όμ € κ°€μž…ν•œ μˆœμ„œλŒ€λ‘œ μ •λ ¬

1. νšŒμ›μ˜ λ‚˜μ΄μ™€ 이름을 member 리슀트 μ•ˆμ— 리슀트 ν˜•νƒœλ‘œ μž…λ ₯λ°›λŠ”λ‹€

2. κ°€μž…ν•œ μˆœμ„œλŒ€λ‘œ μž…λ ₯λ°›κΈ° λ•Œλ¬Έμ— λ‚˜μ΄ 순으둜만 μ •λ ¬ν•œλ‹€

    => λ‚΄μž₯ν•¨μˆ˜ sorted() μ‚¬μš©

# 10814.py

import sys

n = int(sys.stdin.readline())
member = [list(sys.stdin.readline().split()) for _ in range(n)]
member = sorted(member, key=lambda t: int(t[0]))
for i in member:
    print(i[0], i[1])