문제
풀이방법
- (이름,키) 쌍의 튜플을 attendance리스트에 넣어서 관리
- attendance리스트를, lambda로 sort하는 문법을 사용
문법
sorted_list = sorted(my_list, key=lambda x: (x[0], x[1]))
- key값에 비교 기준을 두 개를 넣으면, x[0]이 동일할 경우 x[1]을 비교한다
코드
n,k = map(int,input().split())
attendance = []
for _ in range(n):
name,height = input().split()
attendance.append((name,height))
attendance = sorted(attendance, key=lambda x: (x[0], x[1]))
x,y = attendance[k-1]
print(x,y)