코딩테스트/SW Expert Academy
[D2] 1983. 조교의 성적 매기기
셂
2024. 10. 10. 17:11
1983. 조교의 성적 매기기
✏️ 문제 풀이
- total_scores 리스트를 내림차순으로 정렬하여 sorted_scores라는 새 리스트에 저장
(reverse=True는 리스트를 큰 값에서 작은 값으로 정렬)
- rate: 각 학점 그룹에 포함될 학생 수
- index() 메서드는 리스트에서 특정 값의 첫 번째 인덱스를 반환하므로, K번째 학생이 정렬된 리스트에서 몇 번째에 위치하는지를 알 수 있음.
grades = ['A+', 'A0', 'A-', 'B+', 'B0', 'B-', 'C+', 'C0', 'C-', 'D0']
T = int(input())
for tc in range(1, T + 1):
N, K = map(int, input().split())
total_scores = []
for i in range(N):
midterm, final, assignment = map(int, input().split())
total_score = midterm * 0.35 + final * 0.45 + assignment * 0.2
total_scores.append(total_score)
target_score = total_scores[K - 1]
sorted_scores = sorted(total_scores, reverse=True)
rate = N // 10
ratio_score = sorted_scores.index(target_score) // rate
print(f'#{tc} {grades[ratio_score]}')