結果
問題 | No.139 交差点 |
ユーザー |
![]() |
提出日時 | 2015-06-24 15:36:54 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 143 ms / 5,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 1,918 ms |
コンパイル使用メモリ | 77,084 KB |
実行使用メモリ | 42,396 KB |
最終ジャッジ日時 | 2024-07-07 17:25:25 |
合計ジャッジ時間 | 6,790 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
package coder; import java.util.ArrayList; import java.util.Scanner; public class Main { static int N, L; static int[] X, W, T; public static int solve(){ int t = 0; int d = 0; for (int i = 0; i < N; i++) { t += X[i] - d; d = X[i]; int tmp = (t + W[i] - 1) / T[i]; if((t / T[i]) % 2 == 1) { t = ((t/T[i]) + 1) * T[i]; }else if(tmp % 2 == 1) { t = (tmp + 1) * T[i]; } t += W[i]; d += W[i]; } t += L - d; System.out.println(t); return 0; } public static void main(String[] args){ Scanner S = new Scanner(System.in); N = S.nextInt(); L = S.nextInt(); X = new int[N]; W = new int[N]; T = new int[N]; for (int i = 0; i < N; i++) { X[i] = S.nextInt(); W[i] = S.nextInt(); T[i] = S.nextInt(); } solve(); } }