結果
問題 | No.2808 Concentration |
ユーザー | silv723 |
提出日時 | 2024-07-09 22:44:47 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,559 bytes |
コンパイル時間 | 2,677 ms |
コンパイル使用メモリ | 217,568 KB |
実行使用メモリ | 88,304 KB |
最終ジャッジ日時 | 2024-07-09 22:45:24 |
合計ジャッジ時間 | 34,121 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 402 ms
36,368 KB |
testcase_04 | WA | - |
testcase_05 | AC | 6 ms
5,376 KB |
testcase_06 | AC | 484 ms
49,844 KB |
testcase_07 | WA | - |
testcase_08 | AC | 340 ms
26,316 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 665 ms
64,100 KB |
testcase_12 | WA | - |
testcase_13 | AC | 1,522 ms
86,800 KB |
testcase_14 | AC | 789 ms
75,004 KB |
testcase_15 | AC | 436 ms
40,888 KB |
testcase_16 | AC | 639 ms
65,536 KB |
testcase_17 | AC | 638 ms
63,076 KB |
testcase_18 | WA | - |
testcase_19 | AC | 383 ms
40,408 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 926 ms
76,908 KB |
testcase_23 | AC | 917 ms
84,092 KB |
testcase_24 | AC | 904 ms
86,008 KB |
testcase_25 | AC | 796 ms
77,436 KB |
testcase_26 | AC | 775 ms
79,612 KB |
testcase_27 | AC | 718 ms
70,780 KB |
testcase_28 | AC | 710 ms
70,272 KB |
testcase_29 | WA | - |
testcase_30 | AC | 843 ms
74,496 KB |
testcase_31 | AC | 868 ms
73,216 KB |
testcase_32 | AC | 784 ms
75,900 KB |
testcase_33 | AC | 868 ms
80,764 KB |
testcase_34 | AC | 791 ms
77,948 KB |
testcase_35 | AC | 779 ms
74,364 KB |
testcase_36 | AC | 793 ms
75,768 KB |
testcase_37 | AC | 800 ms
77,052 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 860 ms
78,592 KB |
testcase_41 | AC | 809 ms
73,208 KB |
testcase_42 | AC | 808 ms
74,112 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | WA | - |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 1 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
testcase_48 | AC | 2 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 1 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; template <class S, S (*op)(S, S), S (*e)()> class dynamic_segtree { public: dynamic_segtree(size_t n) : n(n), root(nullptr) {} void set(size_t p, S x) { assert(p < n); set(root, 0, n, p, x); } S get(size_t p) const { assert(p < n); return get(root, 0, n, p); } S prod(size_t l, size_t r) const { assert(l <= r && r <= n); return prod(root, 0, n, l, r); } S all_prod() const { return root ? root->product : e(); } void reset(size_t l, size_t r) { assert(l <= r && r <= n); return reset(root, 0, n, l, r); } template <bool (*f)(S)> size_t max_right(size_t l) const { return max_right(l, [](S x) { return f(x); }); } template <class F> size_t max_right(size_t l, const F& f) const { assert(l <= n); S product = e(); assert(f(product)); return max_right(root, 0, n, l, f, product); } template <bool (*f)(S)> size_t min_left(size_t r) const { return min_left(r, [](S x) { return f(x); }); } template <class F> size_t min_left(size_t r, const F& f) const { assert(r <= n); S product = e(); assert(f(product)); return min_left(root, 0, n, r, f, product); } private: struct node; using node_ptr = std::unique_ptr<node>; struct node { size_t index; S value, product; node_ptr left, right; node(size_t index, S value) : index(index), value(value), product(value), left(nullptr), right(nullptr) {} void update() { product = op(op(left ? left->product : e(), value), right ? right->product : e()); } }; const size_t n; node_ptr root; void set(node_ptr& t, size_t a, size_t b, size_t p, S x) const { if (!t) { t = std::make_unique<node>(p, x); return; } if (t->index == p) { t->value = x; t->update(); return; } size_t c = (a + b) >> 1; if (p < c) { if (t->index < p) std::swap(t->index, p), std::swap(t->value, x); set(t->left, a, c, p, x); } else { if (p < t->index) std::swap(p, t->index), std::swap(x, t->value); set(t->right, c, b, p, x); } t->update(); } S get(const node_ptr& t, size_t a, size_t b, size_t p) const { if (!t) return e(); if (t->index == p) return t->value; size_t c = (a + b) >> 1; if (p < c) return get(t->left, a, c, p); else return get(t->right, c, b, p); } S prod(const node_ptr& t, size_t a, size_t b, size_t l, size_t r) const { if (!t || b <= l || r <= a) return e(); if (l <= a && b <= r) return t->product; size_t c = (a + b) >> 1; S result = prod(t->left, a, c, l, r); if (l <= t->index && t->index < r) result = op(result, t->value); return op(result, prod(t->right, c, b, l, r)); } void reset(node_ptr& t, size_t a, size_t b, size_t l, size_t r) const { if (!t || b <= l || r <= a) return; if (l <= a && b <= r) { t.reset(); return; } size_t c = (a + b) >> 1; reset(t->left, a, c, l, r); reset(t->right, c, b, l, r); t->update(); } }; using S = long long; S op(S a, S b){ return max(a, b); } S e(){ return 0; }; int main(){ long long n, s, h; cin >> n >> s >> h; vector<int> x(n), y(n), z(n); for(int i = 0; i < n; i++){ cin >> x[i] >> y[i] >> z[i]; } vector<long long> ch; for(int i = 0; i < n; i++){ ch.push_back(x[i]); ch.push_back(y[i]); ch.push_back(y[i]+s); ch.push_back(x[i]+h); ch.push_back(y[i]+h); ch.push_back(y[i]-s); ch.push_back(x[i]-h); ch.push_back(y[i]-h); } sort(ch.begin(), ch.end()); dynamic_segtree<S, op, e> d(1LL<<35); vector<pair<int, int>> p(3); vector<long long> sum(3); for(auto a:ch){ if(a < 0) continue; long long cnt = 0; for(int i = 0; i < 3; i++){ while(a-(s+h)*(i+1) > x[p[i].first] && p[i].first < n){ sum[i] -= z[p[i].first]; p[i].first++; } while(a-(s+h)*(i+1)+s >= y[p[i].second] && p[i].second < n){ sum[i] += z[p[i].second]; p[i].second++; } cnt += sum[i]; long long u = d.prod(0, max(0LL, a-(s+h)*(i+1))) + cnt; d.set(a, max(d.get(a), u)); } } cout << d.prod(0, 1LL<<35) << endl; }