[SWEA] 1983 조교의 성적 매기기

김은서·2021년 9월 9일
0

SWEA

목록 보기
31/47

풀이

  1. 주어진 비율대로 곱해서 총점 구하기
  2. total_list에 값 추가하기
  3. 구하고자하는 K번째의 수가 나오면 score에 저장하기
  4. 리스트를 오름차순으로 정렬
  5. K번째 수의 index값 찾기
  6. index가 속해있는 범위에 따라 점수 출력하기
  7. 범위는 10을 기준으로 1씩 차지한다고 생각하여 비율로 계산

Python code

T = int(input())
for tc in range(1, T+1):
    N, K = map(int, input().split())
    total_list = []
    score = 0
    for i in range(N):
        mid, final, ws = map(int, input().split())
        total = mid * 0.35 + final * 0.45 + ws * 0.2
        total_list.append(total)
        if i+1 == K:
            score = total
    total_list.sort()
    idx = total_list.index(score)
    if 0 <= idx < 0.1*N:
        print('#{} D0'.format(tc))
    elif 0.1*N <= idx < 0.2*N:
        print('#{} C-'.format(tc))
    elif 0.2*N <= idx < 0.3*N:
        print('#{} C0'.format(tc))
    elif 0.3*N <= idx < 0.4*N:
        print('#{} C+'.format(tc))
    elif 0.4*N <= idx < 0.5*N:
        print('#{} B-'.format(tc))
    elif 0.5*N <= idx < 0.6*N:
        print('#{} B0'.format(tc))
    elif 0.6*N <= idx < 0.7*N:
        print('#{} B+'.format(tc))
    elif 0.7*N <= idx < 0.8*N:
        print('#{} A-'.format(tc))
    elif 0.8*N <= idx < 0.9*N:
        print('#{} A0'.format(tc))
    elif 0.9*N <= idx < N:
        print('#{} A+'.format(tc))
profile
Gracelog

0개의 댓글