관리 메뉴

솜씨좋은장씨

[BaekJoon] 5523번 : 경기 결과 (Python) 본문

Programming/코딩 1일 1문제

[BaekJoon] 5523번 : 경기 결과 (Python)

솜씨좋은장씨 2022. 5. 8. 12:20
728x90
반응형

코딩 1일 1문제! 오늘의 문제는 백준의 경기 결과 입니다.

 

5523번: 경기 결과

A와 B가 게임을 한다. 게임은 N번의 라운드로 이루어져 있다. 각 라운드에서는, 더 많은 점수를 얻은 사람이 그 라운드의 승자가 된다. 즉, A의 점수가 B의 점수보다 크면 i번째 라운드는 A의 승리

www.acmicpc.net

👨🏻‍💻 코드 ( Solution )

import sys

def match_result(match_scores):
    a_team, b_team = 0, 0
    
    for score in match_scores:
        a_score, b_score = score[0], score[1]
        if a_score > b_score:
            a_team += 1
        elif a_score < b_score:
            b_team += 1
            
    return f"{a_team} {b_team}"


if __name__ == "__main__":
    N = int(sys.stdin.readline())
    
    match_scores = []
    for _ in range(N):
        a_score, b_score = map(int, sys.stdin.readline().split())
        match_scores.append((a_score, b_score))
        
    print(match_result(match_scores))

 

 

GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07

1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.

github.com

Comments