結果

問題 No.3424 Shooting Game
コンテスト
ユーザー littlegirl112
提出日時 2026-01-11 14:19:17
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,335 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,843 ms
コンパイル使用メモリ 222,624 KB
実行使用メモリ 21,124 KB
最終ジャッジ日時 2026-01-11 17:22:15
合計ジャッジ時間 3,761 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
using ll = long long;
#define overload4(a, b, c, d, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
void solve();
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) solve();
    return 0;
}
ll dy[4] = {-1, 0, 1, 0}, dx[4] = {0, 1, 0, -1};
void solve() {
    ll n, t;
    cin >> n >> t;
    constexpr ll T = 2e5 + 10;
    vector<vector<ll>> eve(T);
    rep(i, n) {
        ll l, r, p;
        cin >> l >> r >> p;
        eve[l].push_back(p);
        eve[r + 1].push_back(-p);
    }
    multiset<ll> cur;
    vector<ll> ma(T);
    rep(i, T) {
        for (auto x : eve[i]) {
            if (x > 0) cur.insert(x);
            else cur.erase(cur.find(-x));
        }
        if (!cur.empty()) ma[i] = *cur.rbegin();
    }
    vector<ll> dp(T);
    rep(i, T) {
        if (i < t) dp[i] = ma[i];
        else dp[i] = max(dp[i - 1], dp[i - t] + ma[i]);
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}
0