#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b>N>>V>>L; ll dp[N+2][V+1]; rep(i,N+2)rep(j,V+1)dp[i][j]=LINF; dp[0][V]=0; ll pre=0; rep(i,N){ ll x,v,w;cin>>x>>v>>w; ll dis=x-pre; for(int j=0;j+dis<=V;j++){ dp[i+1][j]=dp[i][j+dis]; } bool check[V+1]={}; for(int j=0;j<=V;j++){ if(chmin(dp[i+1][min(V,j+v)],check[j]?dp[i+1][j]:dp[i+1][j]+w)) check[min(V,j+v)]=true; } // for(int j=0;j<=V;j++) cout<