結果

問題 No.139 交差点
ユーザー htensaihtensai
提出日時 2020-02-14 15:44:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 164 ms / 5,000 ms
コード長 599 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 74,364 KB
実行使用メモリ 54,440 KB
最終ジャッジ日時 2024-04-16 00:17:24
合計ジャッジ時間 7,571 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
54,204 KB
testcase_01 AC 129 ms
53,932 KB
testcase_02 AC 130 ms
54,252 KB
testcase_03 AC 135 ms
54,256 KB
testcase_04 AC 151 ms
54,072 KB
testcase_05 AC 146 ms
54,440 KB
testcase_06 AC 135 ms
53,800 KB
testcase_07 AC 146 ms
54,292 KB
testcase_08 AC 144 ms
54,180 KB
testcase_09 AC 144 ms
54,112 KB
testcase_10 AC 161 ms
54,080 KB
testcase_11 AC 136 ms
54,120 KB
testcase_12 AC 152 ms
54,332 KB
testcase_13 AC 131 ms
54,308 KB
testcase_14 AC 144 ms
54,296 KB
testcase_15 AC 164 ms
54,088 KB
testcase_16 AC 136 ms
54,048 KB
testcase_17 AC 148 ms
54,196 KB
testcase_18 AC 143 ms
54,320 KB
testcase_19 AC 156 ms
54,216 KB
testcase_20 AC 142 ms
54,100 KB
testcase_21 AC 119 ms
53,020 KB
testcase_22 AC 129 ms
54,132 KB
testcase_23 AC 154 ms
54,060 KB
testcase_24 AC 135 ms
54,040 KB
testcase_25 AC 139 ms
54,024 KB
testcase_26 AC 141 ms
54,056 KB
testcase_27 AC 132 ms
54,060 KB
testcase_28 AC 135 ms
53,968 KB
testcase_29 AC 142 ms
54,108 KB
testcase_30 AC 145 ms
54,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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