풀이
- 주어진 비율대로 곱해서 총점 구하기
- total_list에 값 추가하기
- 구하고자하는 K번째의 수가 나오면 score에 저장하기
- 리스트를 오름차순으로 정렬
- K번째 수의 index값 찾기
- index가 속해있는 범위에 따라 점수 출력하기
- 범위는 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))