結果

問題 No.70 睡眠の重要性!
ユーザー mokraimokrai
提出日時 2017-11-01 21:45:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 1,257 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 8,932 KB
最終ジャッジ日時 2023-08-14 16:10:16
合計ジャッジ時間 760 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,876 KB
testcase_01 AC 15 ms
8,840 KB
testcase_02 AC 15 ms
8,704 KB
testcase_03 AC 15 ms
8,888 KB
testcase_04 AC 14 ms
8,932 KB
testcase_05 AC 15 ms
8,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from datetime import time

def main():
    num = int(input())
    total_min = 0
    for i in range(num):
        wakeup, bedtime = input().split()

        wakeup_hour, wakeup_min = wakeup.split(':')
        wakeup = time(int(wakeup_hour), int(wakeup_min))

        bedtime_hour, bedtime_min = bedtime.split(':')
        bedtime = time(int(bedtime_hour), int(bedtime_min))

        minutes = bedtime.minute - wakeup.minute
        if wakeup.hour == bedtime.hour:
            if minutes >= 0:
                total_min += minutes
            else:
                total_min += (24 * 60) + minutes
        elif wakeup.hour < bedtime.hour:
            if minutes >= 0:
                total_min += (60 * (bedtime.hour - wakeup.hour)) + minutes
            else:
                hours = bedtime.hour - wakeup.hour
                total_min += 60 * hours + minutes
        else:
            if minutes >= 0:
                hours = bedtime.hour - wakeup.hour + 24
                total_min += 60 * hours + minutes
            else:
                hours = bedtime.hour - wakeup.hour + 24
                total_min += 60 * hours + minutes

        #print()
        #print(total_min)
        #print()

    print(total_min)



if __name__ == '__main__':
    main()
0