結果
問題 | No.139 交差点 |
ユーザー |
|
提出日時 | 2017-01-31 17:25:38 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 615 bytes |
コンパイル時間 | 767 ms |
コンパイル使用メモリ | 141,328 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 06:48:31 |
合計ジャッジ時間 | 1,668 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd1 = readln.split, n = rd1[0].to!size_t, l = rd1[1].to!int; auto xi = new int[](n), wi = new int[](n), ti = new int[](n); foreach (i; n.iota) { auto rd2 = readln.split.to!(int[]); xi[i] = rd2[0]; wi[i] = rd2[1]; ti[i] = rd2[2]; } auto ct = 0, cx = 0; foreach (x, w, t; lockstep(xi, wi, ti)) { ct += x - cx; cx = x; if (ct / t % 2 == 1 || (ct + w) / t % 2 == 1 && (ct + w) % t != 0) ct = (ct / (2 * t) + 1) * (2 * t); ct += w; cx += w; } ct += l - cx; writeln(ct); }