結果

問題 No.70 睡眠の重要性!
ユーザー Hiroaki Kono
提出日時 2017-10-31 22:37:30
言語 Java
(openjdk 23)
結果
AC  
実行時間 144 ms / 5,000 ms
コード長 855 bytes
コンパイル時間 4,009 ms
コンパイル使用メモリ 74,608 KB
実行使用メモリ 41,608 KB
最終ジャッジ日時 2024-11-22 11:14:34
合計ジャッジ時間 4,696 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No70 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int count = s.nextInt();
        int minutes = 0;
        for (int i = 0; i < count; i++) {
            String[] sleep = s.next().split(":");
            String[] wakeup = s.next().split(":");
            int sleepHour = Integer.parseInt(sleep[0]);
            int wakeupHour = Integer.parseInt(wakeup[0]);
            int sleepMinute = Integer.parseInt(sleep[1]);
            int wakeupMinute = Integer.parseInt(wakeup[1]);
            if (sleepHour > wakeupHour || sleepHour == wakeupHour && sleepMinute > wakeupMinute) {
                wakeupHour += 24;
            }
            minutes += (wakeupHour - sleepHour) * 60 + wakeupMinute - sleepMinute;
        }
        System.out.println(minutes);
    }
}
0