結果

問題 No.70 睡眠の重要性!
ユーザー トミートミー
提出日時 2024-04-13 00:44:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 915 bytes
コンパイル時間 2,672 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 53,540 KB
最終ジャッジ日時 2024-04-13 00:45:02
合計ジャッジ時間 1,268 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,540 KB
testcase_01 AC 35 ms
52,560 KB
testcase_02 AC 36 ms
53,380 KB
testcase_03 AC 35 ms
52,820 KB
testcase_04 AC 35 ms
52,872 KB
testcase_05 AC 35 ms
52,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Time:
    def __init__(self, s: str) -> None:
        f = s.find(":")
        self.h = int(s[0:f])
        self.m = int(s[f+1:])

    def __add__(self, other):
        time = Time("00:00")
        time.h = self.h+other.h
        time.m = self.m+other.m
        time.h += int(time.m/60)
        time.m %= 60
        return time

    def __sub__(self, other):
        time = Time("00:00")
        time.h = self.h-other.h
        time.m = self.m-other.m
        
        if time.m < 0:
            time.h -= 1
            time.m %= 60
        time.h %= 24
        return time

    def show(self):
        print(f"{self.h}:{self.m}")

    def __str__(self):
        return str(self.h*60+self.m)


def main():
    cnt = Time("00:00")
    n = int(input())
    for i in range(n):
        a, b = input().split()
        cnt += (Time(b)-Time(a))
    print(cnt)
    # cnt.show()


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