結果

問題 No.139 交差点
ユーザー htensaihtensai
提出日時 2020-02-14 15:41:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 2,312 ms
コンパイル使用メモリ 74,488 KB
実行使用メモリ 41,872 KB
最終ジャッジ日時 2024-04-16 00:17:16
合計ジャッジ時間 8,256 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
41,808 KB
testcase_01 AC 141 ms
41,480 KB
testcase_02 AC 143 ms
41,448 KB
testcase_03 AC 143 ms
41,480 KB
testcase_04 AC 154 ms
41,560 KB
testcase_05 AC 159 ms
41,872 KB
testcase_06 AC 145 ms
41,108 KB
testcase_07 AC 161 ms
41,828 KB
testcase_08 AC 154 ms
41,376 KB
testcase_09 AC 155 ms
41,604 KB
testcase_10 AC 175 ms
41,212 KB
testcase_11 AC 146 ms
41,088 KB
testcase_12 AC 180 ms
41,648 KB
testcase_13 AC 145 ms
41,252 KB
testcase_14 AC 157 ms
41,728 KB
testcase_15 AC 167 ms
41,740 KB
testcase_16 WA -
testcase_17 AC 159 ms
41,648 KB
testcase_18 AC 153 ms
41,224 KB
testcase_19 AC 155 ms
41,692 KB
testcase_20 AC 148 ms
41,324 KB
testcase_21 AC 141 ms
41,108 KB
testcase_22 AC 141 ms
41,320 KB
testcase_23 AC 176 ms
41,828 KB
testcase_24 AC 139 ms
41,448 KB
testcase_25 AC 149 ms
41,452 KB
testcase_26 AC 150 ms
41,324 KB
testcase_27 AC 145 ms
41,052 KB
testcase_28 AC 142 ms
41,656 KB
testcase_29 AC 154 ms
41,540 KB
testcase_30 AC 155 ms
41,284 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