結果

問題 No.139 交差点
ユーザー 小指が強い人
提出日時 2015-12-03 01:39:51
言語 Ruby
(3.4.1)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 285 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-09-14 08:17:26
合計ジャッジ時間 4,844 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, l = gets.split.map(&:to_i)
time = 0
bx = 0
n.times do
    x, w, t = gets.split.map(&:to_i)
    diff = x - bx
    time += diff
    mt = time % (t * 2)
    if mt < t && mt + w <= t
        time += w
    else
        time += t * 2 - mt + w
    end
    bx = x + w
end
puts time + l - bx
0