제출 #690030

#제출 시각아이디문제언어결과실행 시간메모리
690030moonhero거래 (IZhO13_trading)C++14
100 / 100
214 ms17356 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 3e5 + 5; int 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] = max(u[v], u[v * 2]), u[v * 2 + 1] = max(u[v] + (tm - tl + 1), u[v * 2 + 1]); u[v] = 0; } } void upd (int v, int tl, int tr, int l, int r, int val) { if (tl >= l && tr <= r) { 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; 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...