본문 바로가기
Algorithm

[구현/수학] 백준 5928 Contest Timing - 파이썬(Python)

by jangThang 2022. 7. 30.
반응형

백준 온라인 저지

 

[ Contents ]

     

     

    1. 문제 (링크 참조)

     

    5928번: Contest Timing

    Bessie the cow is getting bored of the milk production industry, and wants to switch to an exciting new career in computing. To improve her coding skills, she decides to compete in the on-line USACO competitions. Since she notes that the contest starts on

    www.acmicpc.net

     

     

     

    2. 문제 풀이

     대회는 11일 11시 11분에 시작합니다. 입력된 대회 종료시간을 통해, Bessie가 응시한 시간을 구해야 합니다.

     

     

     

    3. 코드

    import sys
    input = sys.stdin.readline
    
    # 입력
    D, H, M = map(int, input().split())
    
    # 시간 계산
    time = (D-11)*60*24 + (H-11)*60 + (M-11)
    print(time if time >= 0 else -1)

     [종료시간 - 시작시간]을 하면 응시한 시간을 알 수 있습니다. 만약 음수라면, 종료시간이 11일 11시 11분보다 이전이라는 뜻입니다.

     

    star가 되고나서 Tistory

    반응형

    댓글