백준 5074번: When Do We Finish? #Python

ColorlessDia·2025년 12월 6일

algorithm/baekjoon

목록 보기
748/807
import sys

def time_to_second(time):
    hh, mm = map(int, time.split(':'))

    return (hh * 60) + mm

def second_to_time(sec):
    hh = str(sec // 60).zfill(2)
    mm = str(sec % 60).zfill(2)

    return f'{hh}:{mm}'

input = sys.stdin.readline

D = 24 * 60

while True:
    s1, s2 = map(time_to_second, input().rstrip().split())
    s3 = s1 + s2

    if s3 == 0:
        break

    P = s3 // D
    Q = s3 % D

    time = second_to_time(Q)

    print(f'{time}{f' +{P}' if P else ''}')

0개의 댓글