[백준] 2852번 : NBA 농구 - Python(파이썬)

강재원·2022년 11월 2일
0

[코딩테스트] Python

목록 보기
167/200
post-custom-banner



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

n=int(input())
score1 = 0; m1 = 0; s1 = 0; sum1m = 0; sum1s = 0
score2 = 0; m2 = 0; s2 = 0; sum2m = 0; sum2s = 0

for i in range(n):
    a=list(input().split())
    k=int(a[0])
    ar=a[1].split(':')
    m=int(ar[0])
    s=int(ar[1])

    if k==1:
        if score1==score2:
            m1=m
            s1=s
        score1+=1
        if score1==score2:
            if s>=s2:
                sum2m+=m-m2
                sum2s+=s-s2
            else:
                sum2m+=m-m2-1
                sum2s+=s-s2+60
    else:
        if score1==score2:
            m2=m
            s2=s
        score2+=1
        if score1==score2:
            if s>=s1:
                sum1m+=m-m1
                sum1s+=s-s1
            else:
                sum1m+=m-m1-1
                sum1s+=s-s1+60

sum1m+=sum1s//60; sum1s=sum1s%60
sum2m+=sum2s//60; sum2s=sum2s%60

if score1>score2:
    sum1m+=47-m1
    sum1s+=60-s1
elif score1<score2:
    sum2m+=47-m2
    sum2s+=60-s2

sum1m+=sum1s//60; sum1s=sum1s%60
sum2m+=sum2s//60; sum2s=sum2s%60

print("%02d:%02d"%(sum1m,sum1s))
print("%02d:%02d"%(sum2m,sum2s))
profile
개념정리 & 문법 정리 & 알고리즘 공부
post-custom-banner

0개의 댓글