結果

問題 No.139 交差点
ユーザー ぴろずぴろず
提出日時 2015-01-29 23:45:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 710 bytes
コンパイル時間 2,280 ms
コンパイル使用メモリ 77,816 KB
実行使用メモリ 57,540 KB
最終ジャッジ日時 2023-09-05 08:07:13
合計ジャッジ時間 8,043 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,808 KB
testcase_01 AC 125 ms
55,728 KB
testcase_02 AC 127 ms
55,440 KB
testcase_03 AC 130 ms
55,804 KB
testcase_04 AC 137 ms
55,728 KB
testcase_05 AC 143 ms
53,764 KB
testcase_06 AC 135 ms
55,880 KB
testcase_07 AC 144 ms
55,436 KB
testcase_08 AC 139 ms
55,952 KB
testcase_09 AC 146 ms
55,636 KB
testcase_10 WA -
testcase_11 AC 129 ms
55,448 KB
testcase_12 AC 145 ms
55,844 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 162 ms
55,692 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 142 ms
55,780 KB
testcase_19 AC 159 ms
55,708 KB
testcase_20 AC 139 ms
55,448 KB
testcase_21 WA -
testcase_22 AC 126 ms
55,876 KB
testcase_23 AC 152 ms
56,204 KB
testcase_24 AC 129 ms
55,612 KB
testcase_25 AC 137 ms
55,948 KB
testcase_26 AC 137 ms
55,820 KB
testcase_27 AC 135 ms
55,640 KB
testcase_28 AC 129 ms
55,944 KB
testcase_29 AC 144 ms
55,900 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 < t[i] && ph1 < t[i]) {
				time += gap;
			}else{
				time += t[i] * 2 - ph0 + gap;
			}
		}
		System.out.println(time);
	}

}
0