[백준/파이썬] 4758번 Filling Out the Team 풀이

업데이트:



문제 정보


풀이

문제

선수의 기록(40야드, 몸무게, 벤치프레스)이 주어질 때 조건을 만족하는 포지션을 출력하는 문제입니다.

코드

position_dic = {"Wide Receiver":[4.5, 150, 200],
                "Lineman":[6.0, 300, 500],
                "Quarterback":[5.0, 200, 300]}

while True:
    a, b, c = map(float, input().split())
    if a == b == c == 0: break
    
    result = []

    for key, value in position_dic.items():
        if a <= value[0] and b >= value[1] and c >= value[2]:
            result.append(key)
    
    print(' '.join(result) if result else 'No positions')

설명

각 포지션의 조건을 순회하며 만족 여부를 검사하고, 해당 포지션 이름을 공백으로 이어 출력합니다.



댓글남기기