結果

問題 No.70 睡眠の重要性!
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-09 12:17:48
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,234 bytes
コンパイル時間 3,272 ms
コンパイル使用メモリ 73,736 KB
実行使用メモリ 39,908 KB
最終ジャッジ日時 2023-09-17 18:59:17
合計ジャッジ時間 3,433 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
39,908 KB
testcase_01 AC 127 ms
39,352 KB
testcase_02 AC 127 ms
39,136 KB
testcase_03 AC 130 ms
39,584 KB
testcase_04 AC 130 ms
39,460 KB
testcase_05 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int n = koko.nextInt();
        String[] be = new String[n];
        String[] wak = new String[n];
        int total=0;
        for(int i=0; i<n; i++){
            be[i] = koko.next();
            wak[i] = koko.next();
            String[] bed = be[i].split("\\:");
            String[] wake = wak[i].split("\\:");
            int bedh = Integer.parseInt(bed[0]);
            int bedm = Integer.parseInt(bed[1]);
            int wakeh = Integer.parseInt(wake[0]);
            int wakem = Integer.parseInt(wake[1]);
            int sh = wakeh-bedh;
            int sm = wakem-bedm;
            int rsh, rsm;
            if(sh<0&&sm<0){
               rsh=(24-bedh)+wakeh-1;
               rsm=(60-bedm)+wakem;
            }else if(sh>=0&&sm<0){
                rsh=sh-1;
                rsm=(60-bedm)+wakem;
            }else if(sh<0&&sm>=0){
                rsh=(24-bedh)+wakeh;
                rsm=sm;
            }else{
                rsh=sh;
                rsm=sm;
            }
            total = total+(60*rsh)+rsm;
        }
        System.out.println(total);
    }
}
0