-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKorEngMath.py
More file actions
53 lines (46 loc) · 1.08 KB
/
Copy pathKorEngMath.py
File metadata and controls
53 lines (46 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# N명의 학생 이름과 국어, 영어, 수학 점수가 주어질 때 다음 조건으로 학생의 성적을 정렬하시오.
# 정렬 조건 :
# 1. 국어 점수가 감소하는 순서로
# 2. 국어 점수가 같으면 영어 점수가 증가하는 순서로
# 3. 국어, 영어 점수가 같으면 수학 점수가 감소하는 순서로
# 4. 모든 점수가 같으면 이름이 사전 순으로 증가하는 순서로
n = int(input())
students = []
for _ in range(n):
name, kor, eng, math = input().split()
students.append((name, int(kor), int(eng), int(math)))
# 국어(내림차) -> 영어(오름차) -> 수학(내림차) -> 이름(오름차)
students.sort(key=lambda x: (-x[1], x[2], -x[3], x[0]))
print()
for student in students:
print(student[0])
''' TEST
12
Junkyu 50 60 100
Sangkeun 80 60 50
Sunyoung 80 70 100
Soong 50 60 90
Haebin 50 60 100
Kangsoo 60 80 100
Donghyuk 80 60 100
Sei 70 70 70
Wonseob 70 70 90
Sanghyun 70 70 80
nsj 80 80 80
Taewhan 50 60 90
'''
# Answer
'''
Donghyuk
Sangkeun
Sunyoung
nsj
Wonseob
Sanghyun
Sei
Kangsoo
Haebin
Junkyu
Soong
Taewhan
'''