結果

問題 No.70 睡眠の重要性!
ユーザー l1267976
提出日時 2017-03-15 23:50:34
言語 Java
(openjdk 23)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 891 bytes
コンパイル時間 4,202 ms
コンパイル使用メモリ 80,644 KB
実行使用メモリ 54,252 KB
最終ジャッジ日時 2024-07-04 01:26:34
合計ジャッジ時間 5,556 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

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