jyamethyst21 님의 블로그

백준 5523번 - '경기 결과' (PYTHON 풀이) 본문

CODING 💻

백준 5523번 - '경기 결과' (PYTHON 풀이)

jyamethyst21 2026. 4. 15. 09:17

문제:

 

A, B의 점수가 라운드별로 주어질 때 각각의 승리 횟수를 기록한 뒤, 최종적으로 모든 라운드가 끝난 다음 몇 번씩 이겼는지 그 횟수를 출력하는 문제이다.

 

풀이:

import sys
input = sys.stdin.readline
round = int(input())
a_score, b_score = 0, 0

for i in range(round):
    a_round_score, b_round_score = map(int,input().split())
    if a_round_score > b_round_score:
        a_score += 1
    elif a_round_score < b_round_score:
        b_score += 1
    else:
        pass
print(a_score, b_score)

라운드 수를 입력받고 해당 라운드별로 A, B의 점수를 입력받는다.

그 다음 각 점수를 입력받자마자 어느 쪽의 점수가 더 큰지 비교한 뒤, 이긴 쪽의 변수(a_score, b_score)에 1씩 더한다.

모든 반복문 이후에는 각 변수에 이긴 횟수가 저장되므로 해당 점수를 바로 출력하면 된다.