結果

問題 No.139 交差点
ユーザー tentententen
提出日時 2020-12-02 08:15:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 150 ms / 5,000 ms
コード長 707 bytes
コンパイル時間 2,272 ms
コンパイル使用メモリ 71,512 KB
実行使用メモリ 56,964 KB
最終ジャッジ日時 2023-10-11 04:30:12
合計ジャッジ時間 8,151 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,928 KB
testcase_01 AC 122 ms
55,932 KB
testcase_02 AC 123 ms
55,828 KB
testcase_03 AC 127 ms
55,696 KB
testcase_04 AC 134 ms
55,836 KB
testcase_05 AC 134 ms
55,812 KB
testcase_06 AC 125 ms
56,964 KB
testcase_07 AC 137 ms
56,028 KB
testcase_08 AC 133 ms
55,916 KB
testcase_09 AC 138 ms
55,900 KB
testcase_10 AC 144 ms
56,064 KB
testcase_11 AC 128 ms
55,868 KB
testcase_12 AC 149 ms
55,752 KB
testcase_13 AC 129 ms
56,188 KB
testcase_14 AC 139 ms
55,860 KB
testcase_15 AC 144 ms
55,812 KB
testcase_16 AC 126 ms
56,144 KB
testcase_17 AC 139 ms
56,036 KB
testcase_18 AC 136 ms
55,632 KB
testcase_19 AC 142 ms
56,300 KB
testcase_20 AC 132 ms
56,012 KB
testcase_21 AC 124 ms
55,904 KB
testcase_22 AC 123 ms
56,124 KB
testcase_23 AC 150 ms
56,304 KB
testcase_24 AC 121 ms
56,176 KB
testcase_25 AC 131 ms
56,372 KB
testcase_26 AC 133 ms
55,696 KB
testcase_27 AC 128 ms
56,184 KB
testcase_28 AC 124 ms
55,956 KB
testcase_29 AC 140 ms
55,836 KB
testcase_30 AC 142 ms
55,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int length = sc.nextInt();
        int current = 0;
        int time = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            int w = sc.nextInt();
            int t = sc.nextInt();
            time += x - current;
            current = x;
            if (time / t < (time + w - 1) / t || time / t % 2 == 1) {
                time += 2 * t - time % (2 * t);
            }
            time += w;
            current += w;
        }
        time += length - current;
        System.out.println(time);
    }
}
0