結果

問題 No.139 交差点
ユーザー ぴろずぴろず
提出日時 2015-01-29 23:52:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 711 bytes
コンパイル時間 2,125 ms
コンパイル使用メモリ 78,376 KB
実行使用メモリ 56,252 KB
最終ジャッジ日時 2023-09-05 08:10:35
合計ジャッジ時間 7,989 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,744 KB
testcase_01 AC 129 ms
55,684 KB
testcase_02 AC 126 ms
55,628 KB
testcase_03 AC 132 ms
55,692 KB
testcase_04 AC 138 ms
53,716 KB
testcase_05 AC 140 ms
55,936 KB
testcase_06 AC 130 ms
55,416 KB
testcase_07 AC 142 ms
55,464 KB
testcase_08 AC 139 ms
55,808 KB
testcase_09 AC 144 ms
55,616 KB
testcase_10 AC 152 ms
55,816 KB
testcase_11 AC 130 ms
55,780 KB
testcase_12 AC 153 ms
56,252 KB
testcase_13 AC 130 ms
55,952 KB
testcase_14 AC 141 ms
55,640 KB
testcase_15 AC 161 ms
55,940 KB
testcase_16 AC 133 ms
55,560 KB
testcase_17 AC 142 ms
55,328 KB
testcase_18 AC 142 ms
55,424 KB
testcase_19 AC 149 ms
55,748 KB
testcase_20 AC 136 ms
55,652 KB
testcase_21 AC 124 ms
55,900 KB
testcase_22 AC 123 ms
55,604 KB
testcase_23 AC 159 ms
55,836 KB
testcase_24 AC 127 ms
55,992 KB
testcase_25 AC 135 ms
55,840 KB
testcase_26 AC 135 ms
55,844 KB
testcase_27 AC 129 ms
55,880 KB
testcase_28 AC 130 ms
55,628 KB
testcase_29 AC 144 ms
55,568 KB
testcase_30 AC 142 ms
55,768 KB
権限があれば一括ダウンロードができます

ソースコード

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