Submission #673593

#TimeUsernameProblemLanguageResultExecution timeMemory
673593moday_morningTrading (IZhO13_trading)C++17
100 / 100
167 ms13620 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 500005; 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); } void solve () { 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, 0LL) << " "; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while (t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...