結果

問題 No.139 交差点
コンテスト
ユーザー kou6839
提出日時 2015-02-06 17:08:27
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 603 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,952 ms
コンパイル使用メモリ 81,892 KB
実行使用メモリ 47,176 KB
最終ジャッジ日時 2026-03-08 03:30:24
合計ジャッジ時間 4,764 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.math.*;
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 nowt = 0;
        int nowl = 0;
        for(int i=0;i<n;i++){
        	int a =sc.nextInt();
        	int b =sc.nextInt();
        	int c = sc.nextInt();
        	nowt+=(a-nowl);
        	nowl=a+b;
        	if(nowt%(2*c) <= c-b){
        		nowt+=b;
        	}else{
        		nowt+=b+(2*c-nowt%(2*c));
        	}
        }
        System.out.println(l-nowl+nowt);
        
    }
}		
0