SWEA 1983 조교의 성적 매기기 (파이썬)

shon4bw·2021년 9월 10일
1

🧐1일 1알

목록 보기
21/24
post-thumbnail

내 코드👇

T = int(input())
grades = ['A+', 'A0', 'A-', 'B+', 'B0', 'B-', 'C+', 'C0', 'C-', 'D0']
for tc in range(1, T+1):
    N, K = map(int, input().split())
    total_list = []
    for _ in range(N): # n번 돌아
        mid, final, hws = map(int, input().split())
        total = (mid * 0.35) + (final * 0.45) + (hws*0.2)
        total_list.append(total)
        # [74.6, 92.55000000000001, 88.8, 99.45, 72.35, 85.85000000000001, 96.25, 68.95, 85.5, 85.75]

    # k번 학생의 점수
    # 먼저 k번째 학생의 인덱스를 구해주고
    k_score = total_list[K-1]
    
    # 정렬
    total_list.sort(reverse=True)
    # [99.45, 96.25, 92.55000000000001, 88.8, 85.85000000000001, 85.75, 85.5, 74.6, 72.35, 68.95]
    div = N//10
    final_k_score = total_list.index(k_score) // div

    print('#{} {}'.format(tc, grades[final_k_score]))

포인트💁‍♂

처음에 문제를 잘못 이해해서 굉장히 헤맸..
N/10명의 학생들에게 동일한 평점을 부여할 수 있대
만약 30명의 학생이 있으면, 3명씩 평점이 같겠네!

profile
cut_the_mustard

0개의 댓글