선택은 나의 것

[BOJ 백준] 10825번 국영수 (python) 본문

☽ Algorithm/BOJ

[BOJ 백준] 10825번 국영수 (python)

Algoribi 2020. 7. 27. 11:50

문제

BOJ 10825 : https://www.acmicpc.net/problem/10825

 

10825번: 국영수

첫째 줄에 도현이네 반의 학생의 수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 한 줄에 하나씩 각 학생의 이름, 국어, 영어, 수학 점수가 공백으로 구분해 주어진다. 점수는 1보다 크거나 같고, 1

www.acmicpc.net

접근

python의 lambda 함수를 통해 문제에서 요구하는 조건으로 쉽게 정렬할 수 있다.

코드

n = int(input())
st = []
for i in range(n):
    temp = input().split()
    st.append([temp[0], int(temp[1]), int(temp[2]), int(temp[3])])

st_sort = sorted(st, key=lambda s: (-s[1], s[2], -s[3], s[0]))

for i in st_sort:
    print(i[0])

 

깃 허브 주소 : https://github.com/algoribi/algorithm-study

Comments