#include using namespace std; using SS = int; class DualSegmentTree{ //作用させるものの交換法則が成り立つ時&&lazy->lazyとlazy->datの作用が同じ時専用. //出来ないときは遅延セグ木 出来たとしても改良必須あり. int siz,n; vector dat; void mapping(SS f,SS &x){x = max(x,f);} //FF composition(FF f, FF g){mappingと同じ?} チェック. SS e(){return 0;} public: DualSegmentTree(int N):n(N){ n = N,siz = 1; while(siz < n) siz += siz; dat.resize(siz*2,e()); } DualSegmentTree(vector &A){ n = A.size(),siz = 1; while(siz < n) siz += siz; dat.resize(siz*2,e()); for(int i=0; i>= 1; r >>= 1; } } SS get(int pos){ pos = pos+siz; SS ret = dat.at(pos); while(pos != 1) pos = pos>>=1,mapping(dat.at(pos),ret); return ret; } }; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,T; cin >> N >> T; int n = 200001; vector dp(n+1); DualSegmentTree Z(n); while(N--){ int l,r,p; cin >> l >> r >> p; Z.update(l,r+1,p); } for(int i=0; i