#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(x,y) for(int x = 0;x < (y);x++) #define LLI long long int #define FORR(x,arr) for(auto& x:arr) #define ALL(a) (a.begin()),(a.end()) #define _L(x) cout<<(x)< values; int main() { cin >> N >> L; values.resize(N); REP(i, N) { Data e; cin >> e.X >> e.W >> e.T; values[i] = e; } LLI currentTime = 0; LLI currentPosition = 0; REP(i, N) { currentTime += values[i].X - currentPosition; LLI wait =values[i].GetWait(currentTime); //cout << wait << endl; currentTime += wait; currentTime += values[i].W; currentPosition = values[i].X + values[i].W; } currentTime += L - (values.back().X + values.back().W); cout << currentTime << endl; }