# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81815 | mra2322001 | Trading (IZhO13_trading) | C++14 | 383 ms | 6844 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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, m, t[4*N];
void push(int k, int l, int r){
int mid = (l + r)/2;
if(l==r) return ;
t[k*2] = max(t[2*k], t[k]);
if(t[k])
t[k*2 + 1] = max(t[k*2 + 1], t[k] + 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] = max(t[k], 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];
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |