結果

問題 No.139 交差点
コンテスト
ユーザー tenten
提出日時 2020-12-02 08:15:48
言語 Java
(openjdk 26.0.2.1)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 75 ms / 5,000 ms
+ 761µs
コード長 707 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,273 ms
コンパイル使用メモリ 84,132 KB
実行使用メモリ 44,008 KB
最終ジャッジ日時 2026-08-25 21:47:38
合計ジャッジ時間 5,077 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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