結果

問題 No.70 睡眠の重要性!
ユーザー k_kadorak_kadora
提出日時 2015-06-11 02:32:01
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 5,000 ms
コード長 948 bytes
コンパイル時間 3,219 ms
コンパイル使用メモリ 74,448 KB
実行使用メモリ 57,852 KB
最終ジャッジ日時 2023-09-20 20:43:48
合計ジャッジ時間 4,661 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,428 KB
testcase_01 AC 125 ms
56,472 KB
testcase_02 AC 127 ms
55,804 KB
testcase_03 AC 130 ms
56,000 KB
testcase_04 AC 133 ms
57,852 KB
testcase_05 AC 124 ms
56,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Sleep{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		String[] s = new String[2];
		String[] w = new String[2];
		int n,res=0;
		n = sc.nextInt();
		for(int i = 0;i<n;i++){
			s = sc.next().split(":");
			w = sc.next().split(":");
			if(Integer.parseInt(w[1]) >= Integer.parseInt(s[1])){
				res += Integer.parseInt(w[1]) - Integer.parseInt(s[1]);
				if(Integer.parseInt(w[0])>=Integer.parseInt(s[0])){
					res += (Integer.parseInt(w[0])-Integer.parseInt(s[0]))*60;
				}else{
					res += (Integer.parseInt(w[0])-Integer.parseInt(s[0])+24)*60;
				}
			}else{
				res += Integer.parseInt(w[1]) - Integer.parseInt(s[1]) + 60;
				if(Integer.parseInt(w[0])-1>=Integer.parseInt(s[0])){
					res += (Integer.parseInt(w[0])-1-Integer.parseInt(s[0]))*60;
				}else{
					res += (Integer.parseInt(w[0])-Integer.parseInt(s[0])+23)*60;
				}
			}
		}
		System.out.println(res);
	}
}
0