#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; constexpr int BUCKET_SIZE = 320; ll T[100100], TB[100100 / BUCKET_SIZE + 10], SB[100100 / BUCKET_SIZE + 10]; // [l, r) void update(int l, int r, ll d){ while(l < r && l % BUCKET_SIZE > 0){ T[l] += d; TB[l / BUCKET_SIZE] = max(TB[l / BUCKET_SIZE], T[l] + SB[l / BUCKET_SIZE]); ++l; } while(l < r && r % BUCKET_SIZE > 0){ --r; T[r] += d; TB[r / BUCKET_SIZE] = max(TB[r / BUCKET_SIZE], T[r] + SB[r / BUCKET_SIZE]); } l /= BUCKET_SIZE; r /= BUCKET_SIZE; while(l < r){ SB[l] += d; TB[l] += d; } } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int N; std::cin >> N; for(int i=1;i> T[i]; } { int x = 3; for(int i=N-1;i>=1;--i){ T[i] += x; TB[i / BUCKET_SIZE] = max(TB[i / BUCKET_SIZE], T[i]); x += 3; } } int M; std::cin >> M; for(int i=0;i> l >> r >> d; update(l, r + 1, d); ll res = *max_element(TB, TB + 100100 / BUCKET_SIZE + 3); std::cout << res << std::endl; } }