結果

問題 No.70 睡眠の重要性!
ユーザー yagi2yagi2
提出日時 2017-04-25 16:03:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,102 bytes
コンパイル時間 2,227 ms
コンパイル使用メモリ 81,000 KB
実行使用メモリ 56,608 KB
最終ジャッジ日時 2023-10-11 09:37:55
合計ジャッジ時間 3,594 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
56,608 KB
testcase_01 AC 117 ms
56,220 KB
testcase_02 AC 120 ms
54,080 KB
testcase_03 AC 124 ms
56,188 KB
testcase_04 WA -
testcase_05 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());

        Map<String, String> sleeps = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String G = sc.next();
            String W = sc.next();

            sleeps.put(G, W);
        }

        int sumHour[] = {0};
        int sumMin[]  = {0};
        sleeps.forEach((s, s2) -> {
            int Gh = Integer.parseInt(s.split(":")[0]);
            int Gm = Integer.parseInt(s.split(":")[1]);
            int Wh = Integer.parseInt(s2.split(":")[0]);
            int Wm = Integer.parseInt(s2.split(":")[1]);

            if (Wh - Gh < 0) {
                sumHour[0] += ((24 - Gh) + Wh) - 1;
            } else {
                sumHour[0] += Wh - Gh - 1;
            }
            sumMin[0] += 60 - Gm + Wm;

            sumHour[0] += sumMin[0] / 60;
            sumMin[0] %= 60;
        });
        System.out.println(sumHour[0]*60 + sumMin[0]);
    }
}
0