結果

問題 No.139 交差点
ユーザー kou6839
提出日時 2015-02-06 17:08:27
言語 Java
(openjdk 23)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 603 bytes
コンパイル時間 2,861 ms
コンパイル使用メモリ 74,068 KB
実行使用メモリ 42,072 KB
最終ジャッジ日時 2024-06-23 10:11:09
合計ジャッジ時間 8,357 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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