結果

問題 No.139 交差点
ユーザー uafr_csuafr_cs
提出日時 2015-08-17 04:04:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,398 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 74,884 KB
実行使用メモリ 56,368 KB
最終ジャッジ日時 2023-09-25 12:31:50
合計ジャッジ時間 7,530 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,036 KB
testcase_01 AC 122 ms
55,812 KB
testcase_02 AC 124 ms
55,896 KB
testcase_03 AC 128 ms
56,204 KB
testcase_04 AC 137 ms
55,988 KB
testcase_05 AC 139 ms
55,988 KB
testcase_06 AC 129 ms
56,208 KB
testcase_07 AC 139 ms
56,072 KB
testcase_08 AC 135 ms
55,896 KB
testcase_09 AC 138 ms
55,728 KB
testcase_10 WA -
testcase_11 AC 128 ms
56,140 KB
testcase_12 AC 146 ms
56,048 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 147 ms
55,776 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 138 ms
56,368 KB
testcase_19 AC 142 ms
55,576 KB
testcase_20 AC 136 ms
56,104 KB
testcase_21 AC 122 ms
55,544 KB
testcase_22 AC 122 ms
55,748 KB
testcase_23 AC 150 ms
55,940 KB
testcase_24 AC 123 ms
56,128 KB
testcase_25 AC 133 ms
55,884 KB
testcase_26 AC 134 ms
56,144 KB
testcase_27 AC 129 ms
56,228 KB
testcase_28 AC 127 ms
56,304 KB
testcase_29 AC 138 ms
55,972 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final long L = sc.nextLong();
		
		int[] xs = new int[N];
		int[] ws = new int[N];
		long[] Ts = new long[N];
		
		for(int i = 0; i < N; i++){
			final int x = sc.nextInt();
			final int w = sc.nextInt();
			final long T = sc.nextLong();
			
			xs[i] = x;
			ws[i] = w;
			Ts[i] = T;
		}
		
		int time = 0;
		int pos = 0;
		for(int i = 0; i < N; i++){
			final int arrival_time = time + (xs[i] - pos);
			final int throught_time = arrival_time + ws[i];
			
			if(arrival_time % (2 * Ts[i]) >= Ts[i]){
				final int arrival_wait_time = (int) ((arrival_time + (2 * Ts[i]) - 1) / (2 * Ts[i]) * (2 * Ts[i]));
				time = arrival_wait_time + ws[i];
			}else if(throught_time % (2 * Ts[i]) >= Ts[i]){
				//System.out.println(throught_time);
				final int arrival_wait_time = (int) ((arrival_time + (2 * Ts[i]) - 1) / (2 * Ts[i]) * (2 * Ts[i]));
				//System.out.println(arrival_wait_time);
				time = arrival_wait_time + ws[i];
			}else{
				time = throught_time;
			}
			
			pos = xs[i] + ws[i];
		}
		time += L - (xs[N - 1] + ws[N - 1]);
		
		
		System.out.println(time);
	}
	
}
0