結果

問題 No.2808 Concentration
ユーザー cho435cho435
提出日時 2024-07-27 04:05:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,172 bytes
コンパイル時間 5,223 ms
コンパイル使用メモリ 265,564 KB
実行使用メモリ 19,416 KB
最終ジャッジ日時 2024-07-27 04:06:13
合計ジャッジ時間 16,031 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
19,196 KB
testcase_01 AC 151 ms
19,284 KB
testcase_02 AC 172 ms
19,412 KB
testcase_03 AC 149 ms
19,192 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 61 ms
10,704 KB
testcase_08 AC 24 ms
6,776 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 82 ms
12,488 KB
testcase_11 AC 83 ms
12,132 KB
testcase_12 AC 39 ms
7,300 KB
testcase_13 AC 123 ms
18,708 KB
testcase_14 AC 20 ms
5,376 KB
testcase_15 AC 110 ms
18,388 KB
testcase_16 AC 129 ms
18,136 KB
testcase_17 AC 234 ms
18,904 KB
testcase_18 AC 128 ms
19,280 KB
testcase_19 AC 64 ms
11,044 KB
testcase_20 AC 113 ms
18,860 KB
testcase_21 AC 106 ms
17,860 KB
testcase_22 AC 83 ms
12,148 KB
testcase_23 AC 67 ms
11,700 KB
testcase_24 AC 117 ms
18,412 KB
testcase_25 AC 68 ms
11,076 KB
testcase_26 AC 124 ms
18,312 KB
testcase_27 AC 134 ms
19,252 KB
testcase_28 AC 136 ms
19,416 KB
testcase_29 AC 130 ms
19,148 KB
testcase_30 AC 130 ms
19,216 KB
testcase_31 AC 121 ms
19,356 KB
testcase_32 AC 120 ms
19,236 KB
testcase_33 AC 136 ms
19,232 KB
testcase_34 AC 126 ms
19,352 KB
testcase_35 AC 123 ms
19,088 KB
testcase_36 AC 127 ms
19,232 KB
testcase_37 AC 132 ms
19,196 KB
testcase_38 AC 128 ms
19,280 KB
testcase_39 AC 124 ms
19,240 KB
testcase_40 AC 125 ms
19,192 KB
testcase_41 AC 128 ms
19,408 KB
testcase_42 AC 131 ms
19,212 KB
testcase_43 AC 139 ms
19,080 KB
testcase_44 AC 128 ms
19,268 KB
testcase_45 AC 123 ms
19,088 KB
testcase_46 AC 125 ms
19,352 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 2 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)

template<typename T>
bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
template<typename T>
bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }

struct io_setup {
	io_setup() {
		ios::sync_with_stdio(false);
		std::cin.tie(nullptr);
		cout << fixed << setprecision(15);
	}
} io_setup;

// template atcoder segtree
using S = ll;
S op(S a, S b){
	return max(a, b);
}
S e(){
	return -1e18;
}
using segtree = atcoder::segtree<S,op,e>;

int main(){
	ll n,s,h;
	cin>>n>>s>>h;
	vector<ll> x(n),y(n),z(n);
	rep(i,0,n) cin>>x.at(i)>>y.at(i)>>z.at(i);
	vector<ll> sz(n+1);
	rep(i,0,n) sz.at(i+1)=sz.at(i)+z.at(i);
	segtree dp1(n+1),dp2(n+1);
	rep(i,0,n){
		if(y.at(i)-x.at(i)>s) continue;
		int mny=upper_bound(y.begin(),y.end(),x.at(i)-h)-y.begin();
		int mxx=lower_bound(x.begin(),x.end(),y.at(i)-s)-x.begin();
		if(0<mny) dp1.set(i,dp2.prod(0,mny)-sz.at(i));
		else dp1.set(i,-sz.at(i));
		if(mxx<i+1) dp2.set(i,dp1.prod(mxx,i+1)+sz.at(i+1));
		else dp2.set(i,sz.at(i+1));
	}
	cout<<dp2.all_prod()<<endl;
}
0