반응형

 

문제 설명

https://www.acmicpc.net/problem/9865

 
 

 

 


 

 

제출한 코드

import sys

num = int(sys.stdin.readline())

for i in range(num) :
    a = int(sys.stdin.readline())
    dec = []
    while len(dec)< a*2 :
        dec.extend(map(int,sys.stdin.readline().split()))
    ts_total = 0
    da_total = 0
    for j in range(0,a*2,2) :
        if abs(dec[j]-dec[j+1])==1 :
            if (dec[j]==1 and dec[j+1]==2) :
                ts_total += 6
            elif (dec[j]==2 and dec[j+1]==1) :
                da_total += 6
            else :
                if dec[j]>dec[j+1] :
                    da_total += dec[j]+dec[j+1]
                elif dec[j]<dec[j+1] :
                    ts_total += dec[j]+dec[j+1]
        else :
            if dec[j]>dec[j+1] :
                ts_total += dec[j]
            elif dec[j]<dec[j+1] :
                da_total += dec[j+1]
    print(f"Game {i+1}: Tessa {ts_total} Danny {da_total}")

 

 

 

 

결과

 

 

 

후기

영어에 익숙해지고자 언어 상관 없이 풀고는 있는데, 이번 문제는 특히 이해가 어려웠던 것 같다.

 

힌트를 드리자면 입력은 테스트 케이스 수 - [라운드 수 - 게임 진행(라운드 수*2만큼의 정수가 공백 또는 개행으로 구분되어 출력, 즉, 몇 줄에 걸쳐 입력될 지 알 수 없음.)]의 반복 이다. 그래서 필자는 라운드 수*2 의 정수가 모두 입력될 때까지 입력을 반복(while문)하고 나서 점수를 계산했다.

 

주의할 것은 2를 1로 이겼을 때 점수는 6점을 얻게 되는 것이다. 이외로는 어렵지 않다.

 

 

 

 

 
 
반응형

+ Recent posts