結果

問題 No.139 交差点
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-15 12:57:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 906 bytes
コンパイル時間 2,017 ms
コンパイル使用メモリ 75,280 KB
実行使用メモリ 56,336 KB
最終ジャッジ日時 2023-09-17 20:25:01
合計ジャッジ時間 7,524 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,736 KB
testcase_01 AC 125 ms
55,816 KB
testcase_02 AC 124 ms
55,664 KB
testcase_03 AC 128 ms
55,816 KB
testcase_04 AC 135 ms
54,324 KB
testcase_05 AC 140 ms
55,892 KB
testcase_06 AC 129 ms
55,816 KB
testcase_07 AC 142 ms
55,656 KB
testcase_08 AC 136 ms
55,844 KB
testcase_09 AC 139 ms
55,564 KB
testcase_10 AC 149 ms
56,188 KB
testcase_11 AC 128 ms
55,592 KB
testcase_12 AC 154 ms
55,824 KB
testcase_13 AC 129 ms
56,104 KB
testcase_14 AC 139 ms
55,460 KB
testcase_15 AC 147 ms
55,564 KB
testcase_16 AC 128 ms
55,860 KB
testcase_17 AC 142 ms
55,940 KB
testcase_18 AC 140 ms
55,372 KB
testcase_19 AC 149 ms
56,336 KB
testcase_20 AC 135 ms
55,424 KB
testcase_21 AC 124 ms
55,888 KB
testcase_22 AC 123 ms
55,372 KB
testcase_23 AC 161 ms
56,184 KB
testcase_24 AC 125 ms
56,276 KB
testcase_25 AC 135 ms
55,664 KB
testcase_26 AC 134 ms
55,836 KB
testcase_27 AC 129 ms
55,896 KB
testcase_28 AC 127 ms
56,152 KB
testcase_29 AC 140 ms
55,600 KB
testcase_30 AC 142 ms
55,848 KB
権限があれば一括ダウンロードができます

ソースコード

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();
        int len = koko.nextInt();
        int[] x = new int[n+1];
        int[] wid = new int[n+1];
        int[] tim = new int[n+1];
        int[] ti = new int[n+1];
        int time=0;
        x[0]=0;
        wid[0]=0;
        for(int i=1; i<n+1; i++){
            x[i]=koko.nextInt();
            wid[i]=koko.nextInt();
            tim[i]=koko.nextInt();
            time = time+(x[i]-x[i-1]-wid[i-1]);
            if(time%(2*tim[i])<tim[i]&&(time+wid[i])%(2*tim[i])<=tim[i]){
                ti[i]=wid[i];
            }else{
                ti[i]=wid[i]+((2*tim[i])-(time%(2*tim[i])));
            }
            time = time+ti[i];
        }
        time=time+(len-x[n]-wid[n]);
        System.out.println(time);
    }
}
0