結果

問題 No.3424 Shooting Game
コンテスト
ユーザー shingo0909
提出日時 2026-01-11 15:04:55
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 469 ms / 2,000 ms
コード長 743 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,164 ms
コンパイル使用メモリ 347,640 KB
実行使用メモリ 40,560 KB
最終ジャッジ日時 2026-01-11 17:23:03
合計ジャッジ時間 6,657 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll op(ll a,ll b){
    return max(a,b);
}
ll e(){
    return 0;
}

int main(){
    int n,t;
    cin >> n >> t;
    const int m=4e5+1;
    vector<vector<int>>l(m),r(m);
    rep(i,n){
        int L,R,p;
        cin >> L >> R >> p;
        l[L].push_back(p);
        r[R].push_back(p);
    }
    multiset<ll>s;
    atcoder::segtree<ll,op,e>seg(m);
    rep(i,m){
        for(int j:l[i])s.insert(j);
        if(i!=0)for(int j:r[i-1])s.erase(s.find(j));
        if(s.size()==0)continue;
        seg.set(i,seg.prod(0,max(i-t+1,0))+*s.rbegin());
    }
    cout << seg.all_prod() << endl;
    return 0;
}
0