DHistory

[Baekjoon] Sort - 10825 국영수 본문

Computer Science/Algorithm

[Baekjoon] Sort - 10825 국영수

ddu0422 2023. 9. 9. 23:27

문제

 

10825번: 국영수

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

www.acmicpc.net

 

풀이

"""
1. 국어 점수가 감소하는 순서로
2. 국어 점수가 같으면 영어 점수가 증가하는 순서로
3. 국어 / 영어점수가 같으면 수학 점수가 감소하는 순으로
4. 모든 점수가 같으면 이름이 사전 순으로 증가하는 순서로
"""
import sys

n = int(sys.stdin.readline().rstrip())
scores = []
for _ in range(n):
    input = sys.stdin.readline().rstrip().split()
    scores.append((input[0], *list(map(int, input[1:]))))


def solution(scores):
    return map(lambda x: x[0], sorted(scores, key=lambda x: (-x[1], x[2], -x[3], x[0])))


print(*solution(scores), sep='\n')

 

채점 결과