#include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) template bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; } template 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; int main(){ ll n,s,h; cin>>n>>s>>h; vector x(n),y(n),z(n); rep(i,0,n) cin>>x.at(i)>>y.at(i)>>z.at(i); vector 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