結果
問題 |
No.139 交差点
|
ユーザー |
![]() |
提出日時 | 2020-02-14 15:44:59 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 152 ms / 5,000 ms |
コード長 | 599 bytes |
コンパイル時間 | 2,212 ms |
コンパイル使用メモリ | 74,460 KB |
実行使用メモリ | 41,668 KB |
最終ジャッジ日時 | 2024-10-06 07:58:25 |
合計ジャッジ時間 | 6,765 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
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); } }