제출 #49779

#제출 시각아이디문제언어결과실행 시간메모리
49779mra2322001거래 (IZhO13_trading)C++14
100 / 100
474 ms68224 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, lazy[N*4], lo, hi, price; int t[4*N]; void push(int k, int l, int r){ int x = lazy[k]; if(!x) return ; t[k] = max(t[k], x); lazy[k] = 0; if(l != r){ int m = (l + r)/2; /// l lazy[k << 1] = max(lazy[k << 1], x); /// m + 1 lazy[k << 1 | 1] = max(lazy[k << 1 | 1], x+ m - l + 1); } } void up(int k, int l, int r){ push(k, l, r); if(r < lo || l > hi) return ; if(l >= lo && r <= hi){ lazy[k] = max(price + l - lo, lazy[k]); push(k, l, r); return ; } int m = (l + r)/2; up(k << 1, l, m); up(k << 1 | 1, m + 1, r); t[k] = max(t[k << 1], t[k << 1 | 1]); } int get1(int k, int l, int r, int i){ push(k, l, r); if(l==r) return t[k]; int m = (l + r)/2; if(i >= l && i <= m) return get1(k << 1, l, m, i); return get1(k << 1 | 1, m + 1, r, i); } int main(){ ios_base::sync_with_stdio(0); int q; cin >> n >> q; while(q--){ cin >> lo >> hi >> price; up(1, 1, n); } f1(i, n) cout << get1(1, 1, n, i) << " "; }
#Verdict Execution timeMemoryGrader output
Fetching results...