#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)<>N>>L; int Xi,Wi,Ti; int X=0,T=0; rep(i,N){ cin>>Xi>>Wi>>Ti; T = T + Xi - X; X = Xi;//X+Xi-X if( T%(2*Ti) <= (Ti-Wi) ){ T += Wi; X += Wi; }else{ T += 2*Ti - T%(2*Ti) + Wi; X += Wi; } } T = T + L - X; X = L; P(T); return 0; }