結果

問題 No.70 睡眠の重要性!
ユーザー l1267976l1267976
提出日時 2017-03-15 23:50:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 891 bytes
コンパイル時間 3,184 ms
コンパイル使用メモリ 72,836 KB
実行使用メモリ 56,812 KB
最終ジャッジ日時 2023-09-17 03:44:34
合計ジャッジ時間 4,532 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,812 KB
testcase_01 AC 124 ms
56,132 KB
testcase_02 AC 122 ms
56,128 KB
testcase_03 AC 129 ms
56,208 KB
testcase_04 AC 131 ms
55,708 KB
testcase_05 AC 122 ms
55,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No70 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int result = 0;

        for (int i = 0; i < n; i++) {
            String sleep = sc.next();
            String[] sleeps = sleep.split(":");
            int sleepH = Integer.parseInt(sleeps[0]);
            int sleepM = Integer.parseInt(sleeps[1]);

            String wakeup = sc.next();
            String[] wakeups = wakeup.split(":");
            int wakeupH = Integer.parseInt(wakeups[0]);
            int wakeupM = Integer.parseInt(wakeups[1]);

            int time = ((wakeupH * 60) + wakeupM) - ((sleepH * 60) + sleepM);

            if (time < 0) {
                time += (60 * 24);
            }

            result += time;
        }

        System.out.println(result);

        sc.close();
    }

}
0