結果
| 問題 | 
                            No.139 交差点
                             | 
                    
| コンテスト | |
| ユーザー | 
                            👑  | 
                    
| 提出日時 | 2019-07-09 23:32:33 | 
| 言語 | Lua  (LuaJit 2.1.1734355927)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 342 bytes | 
| コンパイル時間 | 244 ms | 
| コンパイル使用メモリ | 7,072 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-12 19:54:31 | 
| 合計ジャッジ時間 | 1,326 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 28 | 
ソースコード
local n, l = io.read("*n", "*n")
local curpos, curtime = 0, 0
for i = 1, n do
  local x, w, t = io.read("*n", "*n", "*n")
  curtime = curtime + x - curpos
  curpos = x
  local rem = curtime % (2 * t)
  if t - w < rem then
    curtime = curtime + 2 * t - rem
  end
  curpos = curpos + w
  curtime = curtime + w
end
print(curtime + l - curpos)