結果

問題 No.1826 Fruits Collecting
ユーザー torisasami4torisasami4
提出日時 2021-11-14 21:27:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,062 ms / 2,000 ms
コード長 1,206 bytes
コンパイル時間 5,708 ms
コンパイル使用メモリ 273,908 KB
実行使用メモリ 47,740 KB
最終ジャッジ日時 2023-08-28 18:20:13
合計ジャッジ時間 25,024 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 296 ms
20,760 KB
testcase_06 AC 578 ms
34,512 KB
testcase_07 AC 365 ms
24,480 KB
testcase_08 AC 27 ms
5,392 KB
testcase_09 AC 563 ms
32,436 KB
testcase_10 AC 332 ms
23,872 KB
testcase_11 AC 322 ms
21,500 KB
testcase_12 AC 98 ms
11,176 KB
testcase_13 AC 44 ms
7,176 KB
testcase_14 AC 73 ms
9,100 KB
testcase_15 AC 917 ms
47,596 KB
testcase_16 AC 939 ms
47,740 KB
testcase_17 AC 948 ms
47,712 KB
testcase_18 AC 996 ms
46,600 KB
testcase_19 AC 1,010 ms
46,916 KB
testcase_20 AC 1,035 ms
47,624 KB
testcase_21 AC 1,028 ms
46,796 KB
testcase_22 AC 1,062 ms
47,132 KB
testcase_23 AC 1,010 ms
47,048 KB
testcase_24 AC 1,006 ms
46,656 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 148 ms
13,548 KB
testcase_31 AC 350 ms
24,292 KB
testcase_32 AC 141 ms
13,104 KB
testcase_33 AC 615 ms
37,928 KB
testcase_34 AC 496 ms
29,792 KB
testcase_35 AC 79 ms
9,352 KB
testcase_36 AC 603 ms
37,696 KB
testcase_37 AC 406 ms
27,692 KB
testcase_38 AC 261 ms
21,412 KB
testcase_39 AC 239 ms
26,504 KB
testcase_40 AC 314 ms
30,504 KB
testcase_41 AC 63 ms
9,024 KB
testcase_42 AC 10 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
typedef long long ll;

#define pb(...) emplace_back(__VA_ARGS__)
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (n); i++)

ll f(ll a, ll b) {
    return max(a, b);
}

ll e() {
    return (ll)-1e15;
}

int main() {
    int n;
    cin >> n;
    vector<ll> t(n), x(n), v(n);
    rep(i, n) cin >> t[i] >> x[i] >> v[i];
    vector<ll> a(n), b(n);
    rep(i, n) a[i] = t[i] + x[i], b[i] = t[i] - x[i];
    map<ll, int> ma, mb;
    ma[0] = 1, mb[0] = 1;
    rep(i, n) ma[a[i]] = 1, mb[b[i]] = 1;
    int sz_a = 0, sz_b = 0;
    for (auto &e : ma)
        e.second = sz_a++;
    for (auto &e : mb)
        e.second = sz_b++;
    rep(i, n) a[i] = ma[a[i]], b[i] = mb[b[i]];
    segtree<ll, f, e> seg(sz_b);
    vector<pair<ll, pair<ll, ll>>> vec;
    rep(i, n) if (a[i] >= ma[0]) vec.push_back({a[i], {b[i], v[i]}});
    sort(all(vec));
    seg.set(mb[0], 0);
    ll ans = 0;
    for (auto [p, q] : vec) {
        auto [nb, nv] = q;
        ll val = seg.prod(0, nb + 1) + nv;
        seg.set(nb, max(seg.get(nb), val));
    }
    cout << seg.prod(0, sz_b) << endl;
}
0