#include using namespace std; #include #include #include #include typedef long long ll; typedef long double lb; int l[3]; int main(void) { int i,j,k; int memory[2]; int n,l; int x; int w; int t; int now_time = 0; int now_location; cin >> n >> l; now_location = 0; for(i=0;i> x >> w >> t; now_time += x - now_location; if(now_time % (2*t) <= t && now_time+w % (2*t) <= t) { now_time += w; } else { now_time += 2*t - now_time % (2*t) + w; } now_location = x+w; } now_time += l - now_location; printf("%d\n",now_time); return 0; }