結果
問題 | No.2808 Concentration |
ユーザー | ぷら |
提出日時 | 2024-07-12 23:15:01 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 479 ms / 2,000 ms |
コード長 | 5,511 bytes |
コンパイル時間 | 5,238 ms |
コンパイル使用メモリ | 155,828 KB |
実行使用メモリ | 42,356 KB |
最終ジャッジ日時 | 2024-07-12 23:15:43 |
合計ジャッジ時間 | 22,315 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 479 ms
42,260 KB |
testcase_01 | AC | 466 ms
42,224 KB |
testcase_02 | AC | 476 ms
42,284 KB |
testcase_03 | AC | 467 ms
42,308 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 182 ms
20,576 KB |
testcase_08 | AC | 71 ms
10,992 KB |
testcase_09 | AC | 4 ms
6,944 KB |
testcase_10 | AC | 265 ms
26,180 KB |
testcase_11 | AC | 262 ms
25,272 KB |
testcase_12 | AC | 121 ms
13,536 KB |
testcase_13 | AC | 394 ms
40,616 KB |
testcase_14 | AC | 57 ms
8,576 KB |
testcase_15 | AC | 371 ms
39,656 KB |
testcase_16 | AC | 378 ms
39,012 KB |
testcase_17 | AC | 439 ms
41,200 KB |
testcase_18 | AC | 425 ms
42,276 KB |
testcase_19 | AC | 206 ms
22,136 KB |
testcase_20 | AC | 391 ms
41,088 KB |
testcase_21 | AC | 360 ms
38,208 KB |
testcase_22 | AC | 272 ms
24,928 KB |
testcase_23 | AC | 223 ms
24,196 KB |
testcase_24 | AC | 399 ms
39,932 KB |
testcase_25 | AC | 202 ms
22,364 KB |
testcase_26 | AC | 413 ms
39,776 KB |
testcase_27 | AC | 454 ms
42,268 KB |
testcase_28 | AC | 414 ms
42,300 KB |
testcase_29 | AC | 413 ms
42,120 KB |
testcase_30 | AC | 390 ms
42,304 KB |
testcase_31 | AC | 413 ms
42,352 KB |
testcase_32 | AC | 417 ms
42,120 KB |
testcase_33 | AC | 415 ms
42,216 KB |
testcase_34 | AC | 414 ms
42,356 KB |
testcase_35 | AC | 454 ms
42,308 KB |
testcase_36 | AC | 417 ms
42,188 KB |
testcase_37 | AC | 451 ms
42,216 KB |
testcase_38 | AC | 442 ms
42,296 KB |
testcase_39 | AC | 445 ms
42,340 KB |
testcase_40 | AC | 444 ms
42,252 KB |
testcase_41 | AC | 413 ms
42,328 KB |
testcase_42 | AC | 448 ms
42,276 KB |
testcase_43 | AC | 439 ms
42,156 KB |
testcase_44 | AC | 447 ms
42,216 KB |
testcase_45 | AC | 433 ms
42,320 KB |
testcase_46 | AC | 463 ms
42,264 KB |
testcase_47 | AC | 2 ms
6,944 KB |
testcase_48 | AC | 2 ms
6,940 KB |
testcase_49 | AC | 2 ms
6,944 KB |
testcase_50 | AC | 2 ms
6,944 KB |
testcase_51 | AC | 2 ms
6,940 KB |
testcase_52 | AC | 2 ms
6,940 KB |
testcase_53 | AC | 2 ms
6,944 KB |
testcase_54 | AC | 2 ms
6,940 KB |
testcase_55 | AC | 2 ms
6,944 KB |
testcase_56 | AC | 2 ms
6,944 KB |
ソースコード
#include <string.h> #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <list> #include <map> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using ll = long long; using pii = pair<int,int>; using pll = pair<ll,ll>; template <typename T> using vc = vector<T>; template <typename T> using vvc = vector<vector<T>>; template <typename T> using vvvc = vector<vector<vector<T>>>; template<class T> using pq = priority_queue<T,vector<T>,greater<T>>; template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); } template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); } int dx4[] = {1,0,-1,0}; int dy4[] = {0,1,0,-1}; #define overload5(a, b, c, d, e, name, ...) name #define overload4(a, b, c, d, name, ...) name #define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf) #define REP1(i, n) for(ll i = 0; i < (n); ++i) #define REP2(i, a, b) for(ll i = (a); i < (b); ++i) #define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c)) #define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__) #define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf) #define per1(i, n) for(ll i = (n)-1; i >= 0; --i) #define per2(i, a, b) for(ll i = (a)-1; i >= b; --i) #define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c)) #define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__) #define setbits(j, n) for(ll iiiii = (n), j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii)) #define perm(v) for(bool permrepflag = true; (permrepflag ? exchange(permrepflag, false) : next_permutation(all(v)));) #define fi first #define se second #define pb push_back #define ppb pop_back #define ppf pop_front #define drop(s) cout << #s << endl, exit(0) #define si(c) (int)(c).size() #define lb(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{})) #define ub(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{})) #define rng(v, l, r) v.begin() + (l), v.begin() + (r) #define all(c) c.begin(), c.end() #define rall(c) c.rbegin(), c.rend() #define SORT(v) sort(all(v)) #define REV(v) reverse(all(v)) #define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end()) #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define overload2(_1, _2, name, ...) name #define vec(type, name, ...) vector<type> name(__VA_ARGS__) #define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) ll inf = 1001001001001001001; template <typename T> struct LazySegmentTree { int n; vector<T> dat; vector<T>lazy; LazySegmentTree() {}; LazySegmentTree(int N) { n = 1; while(n < N) { n *= 2; } dat.resize(n*2,0); lazy.resize(n*2,0); } void eval(int k,int l,int r) { if(lazy[k] == 0) return; if(k < n) { lazy[k*2] += lazy[k]; lazy[k*2+1] += lazy[k]; } dat[k] += lazy[k]; lazy[k] = 0; } void update(int a, int b, T x, int k, int l, int r) { eval(k,l,r); if(a <= l && r <= b) { lazy[k] += x; eval(k,l,r); } else if(a < r && l < b) { update(a, b, x, k*2, l, (l+r)/2); update(a, b, x, k*2+1, (l+r)/2, r); dat[k] = max(dat[k*2],dat[k*2+1]); } } void update(int a, int b, T x) {//[a,b) update(a, b, x, 1, 0, n); } T query_sub(int a, int b, int k, int l, int r) { eval(k,l,r); if (r <= a || b <= l) { return -inf; } else if (a <= l && r <= b) { return dat[k]; } else { T vl = query_sub(a, b, k*2, l, (l+r)/2); T vr = query_sub(a, b, k*2+1, (l+r)/2, r); return max(vl,vr); } } T query(int a, int b) {//[a,b) return query_sub(a, b, 1, 0, n); } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n,s,h; cin >> n >> s >> h; vc<int>x(n),y(n),z(n),cmp; rep(i,n) { cin >> x[i] >> y[i] >> z[i]; cmp.pb(x[i]); cmp.pb(y[i]); } cmp.pb(2002002002); UNIQUE(cmp); LazySegmentTree<ll>Seg(si(cmp)); vvc<pii>tmp(si(cmp)); rep(i,n) { int it1 = lower_bound(all(cmp),x[i])-cmp.begin(); int it2 = lower_bound(all(cmp),y[i])-cmp.begin(); tmp[it2].pb({it1,z[i]}); } ll ans = 0; vc<ll>dp(si(cmp)); rep(i,si(cmp)-1) { for(auto j:tmp[i]) { Seg.update(0,j.fi+1,j.se); } int it = lower_bound(all(cmp),cmp[i]-s)-cmp.begin(); ll mx = Seg.query(it,i+1); chmax(ans,mx); int nxt = lower_bound(all(cmp),cmp[i]+h)-cmp.begin(); chmax(dp[nxt],mx); chmax(dp[i+1],dp[i]); Seg.update(i,i+1,dp[i]); } cout << ans << "\n"; }