제출 #89387

#제출 시각아이디문제언어결과실행 시간메모리
89387turbat거래 (IZhO13_trading)C++14
100 / 100
503 ms40632 KiB
#include <bits/stdc++.h> using namespace std; #define N 300005 int n, m, l, r, x, seg[4 * N], ans[N]; void update(int node, int L, int R, int l, int r){ if (L > r || l > R) return; if (l <= L && r >= R){ seg[node] = max(seg[node], x); return; } int mid = (L + R)/2; update(node * 2, L, mid, l, r); update(node * 2 + 1, mid + 1, R, l, r); } void res(int node, int l, int r){ if (l == r){ ans[l] = seg[node]; return; } int mid = (l + r)/2; seg[node * 2] = max(seg[node], seg[node * 2]); res(node * 2, l, mid); seg[node * 2 + 1] = max(seg[node], seg[node * 2 + 1]); res(node * 2 + 1, mid + 1, r); } int main (){ cin >> n>> m; for (int i = 0;i < 4 * n;i++) seg[i] = -1e9; while (m--){ cin >> l>> r>> x; x -= (l - 1); update(1, 1, n, l, r); } res(1, 1, n); for (int i = 0;i < n;i++) cout << max(ans[i + 1] + i, 0)<<" "; }
#Verdict Execution timeMemoryGrader output
Fetching results...