結果
問題 |
No.2808 Concentration
|
ユーザー |
![]() |
提出日時 | 2024-07-12 22:40:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 402 ms / 2,000 ms |
コード長 | 1,660 bytes |
コンパイル時間 | 1,507 ms |
コンパイル使用メモリ | 123,576 KB |
最終ジャッジ日時 | 2025-02-22 04:44:38 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 57 |
ソースコード
#include <algorithm> #include <atcoder/lazysegtree.hpp> #include <atcoder/segtree.hpp> #include <cassert> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <tuple> #include <utility> #include <vector> using namespace std; using i8 = int8_t; using i32 = int; using i64 = long long; // using i128 = __int128; using u64 = unsigned long long; using ll = long long; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } i64 pow(i64 j, i64 n) { i64 res = 1; while (n > 0) { if (n & 1) res *= j; j *= j; n >>= 1; } return res; } i64 op(i64 a, i64 b) { return max(a, b); } i64 e() { return 0; } i64 m(i64 f, i64 x) { return x + f; } i64 comp(i64 f, i64 g) { return f + g; } i64 n, s, h; void _main() { cin >> n >> s >> h; vector<i64> x(n); vector<i64> y(n); vector<i64> z(n); for (i64 i = 0; i < n; i++) { cin >> x[i] >> y[i] >> z[i]; } atcoder::segtree<i64, op, e> xs(n); atcoder::lazy_segtree<i64, op, e, i64, m, comp, e> ys(n); atcoder::lazy_segtree<i64, op, e, i64, m, comp, e> add(n); i64 ans = 0; for (i64 i = n - 1; i >= 0; i--) { i64 a = upper_bound(x.begin(), x.end(), y[i] + h) - x.begin(); if (a < n) { ys.set(i, xs.prod(a, n)); } i64 b = upper_bound(y.begin(), y.end(), x[i] + s) - y.begin(); ys.apply(i, b, z[i]); add.apply(i, b, z[i]); for (i64 j = b; j < n; j++) { if (add.get(j) == 0) { break; } add.set(j, 0); } xs.set(i, ys.prod(i, n)); ans = max(ans, xs.get(i)); } cout << ans << "\n"; }