結果

問題 No.139 交差点
ユーザー cherrypi59
提出日時 2019-04-11 08:31:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 546 bytes
コンパイル時間 1,420 ms
コンパイル使用メモリ 167,940 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-18 05:01:42
合計ジャッジ時間 2,381 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int X[105], W[105], T[105];

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, L; cin >> N >> L;
    for(int i=0;i<N;i++) cin >> X[i] >> W[i] >> T[i];

    int t = X[0];
    X[N] = L;
    for(int i=0;i<N;i++){
        int k = t / T[i], x = t % T[i];
        if(k%2) t += T[i] - x + W[i];
        else{
            if(x<=T[i]-W[i]) t += W[i];
            else t += 2 * T[i] - x + W[i];
        }
        t += X[i+1] - X[i] - W[i];
    }

    cout << t << endl;
    return 0;
}
0