結果
| 問題 |
No.2808 Concentration
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-27 00:11:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,462 bytes |
| コンパイル時間 | 4,344 ms |
| コンパイル使用メモリ | 264,992 KB |
| 最終ジャッジ日時 | 2025-02-23 19:00:10 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 WA * 17 |
ソースコード
#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 a + b;
}
S e(){
return 0;
}
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);
map<ll,vector<ll>> el;
vector<ll> al={0};
rep(i,0,n){
al.push_back(x.at(i));
al.push_back(y.at(i));
el[x.at(i)].push_back(y.at(i));
}
sort(al.begin(),al.end());
al.erase(unique(al.begin(),al.end()),al.end());
int m=al.size();
auto get_idx=[&](ll a){
return lower_bound(al.begin(),al.end(),a)-al.begin();
};
auto get_uidx=[&](ll a){
return upper_bound(al.begin(),al.end(),a)-al.begin();
};
segtree seg(m);
rep(i,0,n){
seg.set(get_idx(y.at(i)),z.at(i));
}
vector<ll> dp(m+1,0);
rep(i,0,m){
ll nw=al.at(i);
ll nx=get_idx(nw+s+h);
chmax(dp.at(nx),dp.at(i)+seg.prod(0,get_uidx(nw+s)));
if(el.count(nw)){
for(auto y:el.at(nw)){
seg.set(get_idx(y),0);
}
}
chmax(dp.at(i+1),dp.at(i));
}
cout<<dp.back()<<endl;
}