結果
問題 |
No.139 交差点
|
ユーザー |
|
提出日時 | 2016-08-17 16:42:42 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 87 ms / 5,000 ms |
コード長 | 589 bytes |
コンパイル時間 | 483 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-11-07 18:48:57 |
合計ジャッジ時間 | 3,939 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
コンパイルメッセージ
Syntax OK
ソースコード
class Calc0139 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @n, @l = args.shift.map(&:to_i) @xs, @ws, @ts = args.map { |l| l.map(&:to_i) }.transpose end def run cx, ct = 0, 0 @xs.zip(@ws, @ts) do |x, w, t| ct += x - cx sig = (ct / t) % 2 if sig == 1 ct = ((ct / t) + 1) * t else rest = t - (ct % t) if rest < w ct = ((ct / t) + 2) * t end end cx = x + w ct += w end ct + (@l - cx) end end puts Calc0139.new(STDIN.readlines).run if __FILE__ == $0