Submission #690028

#TimeUsernameProblemLanguageResultExecution timeMemory
690028moonheroTrading (IZhO13_trading)C++14
0 / 100
0 ms340 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3e5 + 5; ll r[N * 4], tc[N * 4], u[N * 4]; void push (int v, int tl, int tr) { if (u[v]) { int tm = (tl + tr) / 2; u[v * 2] = u[v], u[v * 2 + 1] = u[v] + (tm - tl + 1); u[v] = 0, tc[v] = 0; } } void upd (int v, int tl, int tr, int l, int r, ll val) { if (tl >= l && tr <= r) { tc[v]++, u[v] = max(u[v], val + tl - l); return; } if (tl > r || tr < l) return; int tm = (tl + tr) / 2; push(v, tl, tr); upd(v * 2, tl, tm, l, r, val); upd(v * 2 + 1, tm + 1, tr, l, r, val); } void out (int v, int tl, int tr) { if (tl == tr) { cout << u[v] << ' '; return; } int tm = (tl + tr) / 2; push(v, tl, tr); out(v * 2, tl, tm); out(v * 2 + 1, tm + 1, tr); } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) { int n; cin >> n; for (int i = 0; i <= n * 4; i++) r[i] = 0, u[i] = 0, tc[i] = 0; int q; cin >> q; while (q--) { int l, r, x; cin >> l >> r >> x; upd(1, 1, n, l, r, x); } out(1, 1, n); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...