結果

問題 No.70 睡眠の重要性!
ユーザー YOSHIYOSHI
提出日時 2021-02-27 12:19:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 842 bytes
コンパイル時間 2,750 ms
コンパイル使用メモリ 77,808 KB
実行使用メモリ 50,412 KB
最終ジャッジ日時 2024-04-10 15:35:03
合計ジャッジ時間 3,636 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
50,240 KB
testcase_01 AC 45 ms
50,100 KB
testcase_02 AC 47 ms
50,096 KB
testcase_03 AC 47 ms
50,412 KB
testcase_04 AC 46 ms
50,016 KB
testcase_05 AC 46 ms
49,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No00000070_Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		int ans = 0;
		for(int i = 0; i < n ; i++) {
			String[] timeArr = br.readLine().split(" ");
			ans += getSleepTime(timeArr);
		}
		System.out.println(ans);
	}

	private static int getSleepTime(String[] arr) {
		int h1 = Integer.parseInt(arr[0].split(":")[0]);
		int m1 = Integer.parseInt(arr[0].split(":")[1]);
		int h2 = Integer.parseInt(arr[1].split(":")[0]);
		int m2 = Integer.parseInt(arr[1].split(":")[1]);

		if(m1 > m2) {
			h2--;
			m2 += 60;
		}
		if(h1 > h2) {
			h2 += 24;
		}
		return (h2 - h1) * 60 + (m2 - m1);
	}
}
0