https://www.acmicpc.net/problem/10825
solution
lambda x: (-국어, 영어, -수학, 이름)
※ 형식 에러
student = sorted(student, key=lambda x: (-x[1], x[2], -x[3), x[0]))
-x[1] → -int(x[1])
import sys
N = int(sys.stdin.readline())
student = [list((sys.stdin.readline().split())) for _ in range(N)]
student = sorted(student, key=lambda x: (-int(x[1]), int(x[2]), -int(x[3]), x[0]))
for stu in student:
print(stu[0])
78708KB
500ms
다른 사람 풀이
from sys import stdin
n = int(stdin.readline().rstrip())
lst = []
for i in range(n):
name, k, e, m = stdin.readline().split()
lst.append((name, int(k), int(e), int(m)))
lst.sort(key=lambda item: item[0])
lst.sort(key=lambda item: item[3], reverse=True)
lst.sort(key=lambda item: item[2])
lst.sort(key=lambda item: item[1], reverse=True)
for item in lst:
print(item[0])
44736KB
396ms
'알고리즘 > 정렬' 카테고리의 다른 글
자바 | 백준 | 10814 | 나이순 정렬 | Comparator, 람다식 (0) | 2021.02.05 |
---|---|
파이썬 | 백준 | 2865 | 나는 위대한 슈퍼스타K | 소수 출력 (0) | 2020.08.15 |
백준 | 파이썬 | 1431 | 시리얼 번호 (0) | 2020.08.06 |
파이썬 | 백준 | 1728 | 구슬 굴리기 | list에 있는지 : in 없는지 : not in (0) | 2020.08.04 |