문제📖
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2Fb155031f-c911-4906-894e-4f86036a45d6%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-04-01%20%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB%2010.35.54.png)
풀이🙏
- 민준이는 정신을 늦게 차렸다.
- 첫째 줄에 n(3~50)이 입력된다.
- 둘째 줄 부터 n+1행까지 친구의 이름과 점수가 공백으로 분리되어 입력된다.
- 세 번째로 높은 학생의 이름을 출력한다.
-> sorted
+ key
, lambda
+ reverse
+ indexing
으로 구현하였다.
코드💻
import sys
def sort_score(n):
student = []
for i in range(n):
name, score = input().split()
score = int(score)
student.append([name, score])
result = sorted(student, key = lambda x : x[1], reverse = True)
return result[2][0]
n = int(sys.stdin.readline())
print(sort_score(n))
결과😎
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2Fd17e5128-f9e0-40bf-a699-8024dda6720b%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-04-01%20%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB%2011.01.35.png)
출처 && 깃허브📝
https://codeup.kr/problem.php?id=1420
github