Submission #83710

#TimeUsernameProblemLanguageResultExecution timeMemory
83710mra2322001Trading (IZhO13_trading)C++14
100 / 100
287 ms7112 KiB
#include <bits/stdc++.h> #define f0(i, n) for(int i(0); i < (n); i++) #define f1(i, n) for(int i(1); i <= n; i++) using namespace std; typedef long long ll; const int N = 300002; int n, t[N*4]; void up(int k, int l, int r, int i, int j, int x){ if(r < i || l > j) return ; if(l >= i && r <= j){ t[k] = max(t[k], l - i + x); return ; } int m = (l + r)/2; up(k*2, l, m, i, j, x); up(k*2 + 1, m + 1, r, i, j, x); } int res= 0 ; void get1(int k, int l, int r, int i){ if(l==r){ res = max(res, t[k]); return ; } if(t[k]) res = max(res, t[k] + i - l); int m = (l + r)/2; if(i <= m) get1(k*2, l, m, i); else get1(k*2 + 1, m + 1, r, i); } int main(){ ios_base::sync_with_stdio(0); int q; cin >> n >> q; while(q--){ int l, r, x; cin >> l >> r >> x; up(1, 1, n, l, r, x); } f1(i, n) { res = 0; get1(1, 1, n, i); cout << res << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...