結果

問題 No.139 交差点
ユーザー Navier_Boltzmann
提出日時 2023-01-21 17:27:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 551 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 57,624 KB
最終ジャッジ日時 2024-06-24 00:39:22
合計ジャッジ時間 2,534 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N,L = map(int,input().split())
XWT = [tuple(map(int,input().split())) for _ in range(N)]
now = 0
time = 0
for x,w,T in XWT:
    time += x-now
    now = x
    if time//T%2==0:
        if (time+w-1)//T==time//T:
            now = x+w
            time += w
        else:
            now = x+w
            time = w + T*(time//T + 2)
    else:
        now = x+w
        time = w + T*(time//T + 1)
print(time + L - now)
0