結果

問題 No.139 交差点
ユーザー htensai
提出日時 2020-02-14 15:24:37
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 619 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 74,500 KB
実行使用メモリ 56,608 KB
最終ジャッジ日時 2024-10-06 07:57:57
合計ジャッジ時間 6,785 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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