結果

問題 No.3424 Shooting Game
コンテスト
ユーザー i_taku
提出日時 2026-01-16 13:54:07
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 727 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,006 ms
コンパイル使用メモリ 219,984 KB
実行使用メモリ 28,396 KB
最終ジャッジ日時 2026-01-16 13:54:12
合計ジャッジ時間 4,806 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

constexpr int SIZE = 2 << 17;
vector<int> LP[SIZE], RP[SIZE];
long long dp[SIZE];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, T;
    cin >> N >> T;
    while (N--) {
        int l, r, p;
        cin >> l >> r >> p;
        // 1-indexed
        LP[l + 1].push_back(p);
        RP[r + 1].push_back(p);
    }

    multiset<int> ms;
    ms.insert(0);
    for (int i = 1; i < SIZE; i++) {
        for (int p : LP[i]) {
            ms.insert(p);            
        }
        dp[i] = max(dp[i - 1], dp[max(0, i - T)] + *ms.rbegin());
        for (int p : RP[i]) {
            ms.erase(ms.find(p));
        }
    }
    cout << dp[SIZE - 1] << endl;
}
0