結果

問題 No.139 交差点
ユーザー ぴろずぴろず
提出日時 2015-01-29 23:49:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 2,039 ms
コンパイル使用メモリ 74,264 KB
実行使用メモリ 57,780 KB
最終ジャッジ日時 2023-09-05 08:08:55
合計ジャッジ時間 7,902 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,696 KB
testcase_01 AC 126 ms
55,676 KB
testcase_02 AC 124 ms
55,764 KB
testcase_03 AC 129 ms
55,784 KB
testcase_04 AC 136 ms
55,676 KB
testcase_05 AC 141 ms
55,940 KB
testcase_06 AC 129 ms
55,460 KB
testcase_07 AC 144 ms
55,932 KB
testcase_08 AC 138 ms
55,676 KB
testcase_09 AC 144 ms
55,744 KB
testcase_10 WA -
testcase_11 AC 133 ms
55,776 KB
testcase_12 AC 154 ms
55,848 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 160 ms
56,096 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 141 ms
55,764 KB
testcase_19 AC 150 ms
55,872 KB
testcase_20 AC 138 ms
55,656 KB
testcase_21 WA -
testcase_22 AC 126 ms
55,800 KB
testcase_23 AC 156 ms
55,952 KB
testcase_24 AC 128 ms
57,780 KB
testcase_25 AC 137 ms
55,440 KB
testcase_26 AC 137 ms
55,804 KB
testcase_27 AC 130 ms
55,740 KB
testcase_28 AC 130 ms
55,884 KB
testcase_29 AC 141 ms
55,904 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package no139;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int[] x = new int[n+2];
		int[] w = new int[n+2];
		int[] t = new int[n+2];
		x[0] = 0;
		w[0] = 0;
		t[0] = 10;
		for(int i=1;i<=n;i++) {
			x[i] = sc.nextInt();
			w[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		x[n+1] = l;
		long time = 0;
		for(int i=0;i<=n;i++) {
			long gap = x[i+1] - x[i];
			long ph0 = time % (t[i] * 2);
			long ph1 = (time + w[i]) % (t[i] * 2);
			if (ph0 <= ph1 && ph1 < t[i]) {
				time += gap;
			}else{
				time += t[i] * 2 - ph0 + gap;
			}
		}
		System.out.println(time);
	}

}
0