結果

問題 No.139 交差点
ユーザー uafr_csuafr_cs
提出日時 2015-08-17 04:01:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,399 bytes
コンパイル時間 2,138 ms
コンパイル使用メモリ 75,432 KB
実行使用メモリ 58,168 KB
最終ジャッジ日時 2023-09-25 12:31:40
合計ジャッジ時間 7,779 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,776 KB
testcase_01 AC 128 ms
55,724 KB
testcase_02 AC 127 ms
56,148 KB
testcase_03 AC 134 ms
56,276 KB
testcase_04 AC 137 ms
56,056 KB
testcase_05 AC 140 ms
56,264 KB
testcase_06 AC 128 ms
56,188 KB
testcase_07 AC 140 ms
55,608 KB
testcase_08 AC 137 ms
55,724 KB
testcase_09 AC 138 ms
55,592 KB
testcase_10 WA -
testcase_11 AC 129 ms
56,108 KB
testcase_12 AC 152 ms
55,720 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 149 ms
55,672 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 141 ms
55,668 KB
testcase_19 AC 148 ms
56,000 KB
testcase_20 AC 132 ms
55,744 KB
testcase_21 WA -
testcase_22 AC 123 ms
53,840 KB
testcase_23 AC 150 ms
55,940 KB
testcase_24 AC 124 ms
55,952 KB
testcase_25 AC 134 ms
55,992 KB
testcase_26 AC 132 ms
55,836 KB
testcase_27 AC 127 ms
55,916 KB
testcase_28 AC 131 ms
55,520 KB
testcase_29 AC 139 ms
55,696 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) ((throught_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