結果
| 問題 |
No.139 交差点
|
| コンテスト | |
| ユーザー |
ぴろず
|
| 提出日時 | 2015-01-29 23:49:01 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 710 bytes |
| コンパイル時間 | 2,590 ms |
| コンパイル使用メモリ | 77,012 KB |
| 実行使用メモリ | 55,976 KB |
| 最終ジャッジ日時 | 2024-06-23 04:15:36 |
| 合計ジャッジ時間 | 7,650 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 7 |
ソースコード
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);
}
}
ぴろず