본문 바로가기

정렬1

[백준✨] 10825번 <국영수> / Python 문제풀이 해답) import sys def input(): return sys.stdin.readline().rstrip() scores = [] for _ in range(int(input())): name, kor, eng, math = input().split() kor, eng, math = map(int, [kor, eng, math]) ''' 정렬의 우선순위는 1. 국어 내림차순 2. 영어 오름차순 3. 수학 내림차순 4. 이름 오름차순 이 순서에 맞게 튜플 형태로 리스트에 넣어준다. ''' scores.append((kor, eng, math, name)) result = sorted( scores, key=lambda score: (-score[0], score[1], -score[2], score.. 2020. 9. 22.