제출 #81814

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