Skip to content

National competition selection exam

1. Problem

해당 문제는 여기에서 확인하실 수 있습니다.

2. Answer

def solution(rank, attendance):
    answer = 0
    # 참석 가능한 학생 필터링
    candidates = []
    for i in range(len(attendance)):
        if attendance[i]:
            candidates.append(i)
    
    # 등수와 인덱스를 튜플로 저장 후 정렬
    ranked = []
    for idx in candidates:
        ranked.append((rank[idx], idx))
    ranked.sort()
    
    # 상위 3명 추출
    a = ranked[0][1]
    b = ranked[1][1]
    c = ranked[2][1]
    
    answer = 10000 * a + 100 * b + c
    return answer