結果

問題 No.139 交差点
ユーザー erbowl
提出日時 2025-01-28 14:56:28
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 861 bytes
コンパイル時間 3,955 ms
コンパイル使用メモリ 311,284 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-28 14:56:34
合計ジャッジ時間 5,029 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;

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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// std::cout << *s.find_by_order(1) << std::endl; // 2

signed main(){
    // これがないと落ちることがある
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll n,l;
    cin >> n>>l;
    ll cnt = 0;
    ll now = 0;

    for (ll i = 0; i < n; i++){
        ll x,w,t;
        cin >> x>>w>>t;
        cnt += x-now;
        now = x;
        auto c = cnt%(2*t);
        if(w+c<=t){
            cnt+=w;
            now=x+w;
        }else{
            cnt+=2*t-c+w;
            now=x+w;
        }
    }
    cout << cnt+l-now << endl;
}
0