제출 #83709

#제출 시각아이디문제언어결과실행 시간메모리
83709mra2322001거래 (IZhO13_trading)C++14
0 / 100
331 ms66560 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], pos[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); pos[k] = 1; 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(pos[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...