結果

問題 No.1826 Fruits Collecting
ユーザー torisasami4torisasami4
提出日時 2021-11-14 21:39:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 1,457 bytes
コンパイル時間 4,369 ms
コンパイル使用メモリ 276,944 KB
実行使用メモリ 47,768 KB
最終ジャッジ日時 2023-08-28 18:19:37
合計ジャッジ時間 15,528 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 166 ms
20,584 KB
testcase_06 AC 303 ms
34,404 KB
testcase_07 AC 198 ms
24,392 KB
testcase_08 AC 17 ms
5,460 KB
testcase_09 AC 303 ms
31,088 KB
testcase_10 AC 188 ms
23,536 KB
testcase_11 AC 180 ms
21,680 KB
testcase_12 AC 63 ms
11,028 KB
testcase_13 AC 29 ms
7,016 KB
testcase_14 AC 48 ms
9,168 KB
testcase_15 AC 553 ms
46,564 KB
testcase_16 AC 547 ms
47,336 KB
testcase_17 AC 531 ms
47,260 KB
testcase_18 AC 516 ms
46,616 KB
testcase_19 AC 510 ms
46,720 KB
testcase_20 AC 507 ms
47,124 KB
testcase_21 AC 507 ms
47,276 KB
testcase_22 AC 514 ms
46,336 KB
testcase_23 AC 505 ms
47,484 KB
testcase_24 AC 514 ms
47,768 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 87 ms
13,472 KB
testcase_31 AC 189 ms
23,996 KB
testcase_32 AC 80 ms
13,016 KB
testcase_33 AC 326 ms
38,088 KB
testcase_34 AC 263 ms
28,748 KB
testcase_35 AC 51 ms
9,340 KB
testcase_36 AC 320 ms
38,112 KB
testcase_37 AC 221 ms
27,532 KB
testcase_38 AC 146 ms
22,300 KB
testcase_39 AC 129 ms
27,240 KB
testcase_40 AC 176 ms
29,440 KB
testcase_41 AC 33 ms
9,104 KB
testcase_42 AC 6 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,380 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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    assert(1 <= n && n <= (int)2e5);
    vector<ll> t(n), x(n), v(n);
    rep(i, n) cin >> t[i] >> x[i] >> v[i];
    rep(i,n) assert(1 <= t[i] && t[i] <= (int)1e9);
    rep(i,n) assert((int)-1e9 <= x[i] && x[i] <= (int)1e9);
    rep(i,n) assert(1 <= v[i] && v[i] <= (int)1e9);
    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