# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
322006 | jovan_b | Trading (IZhO13_trading) | C++17 | 222 ms | 6252 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>
using namespace std;
typedef long long ll;
typedef long double ld;
int seg[2000005];
void upd(int node, int l, int r, int tl, int tr, int val){
if(tl > r || l > tr) return;
if(tl <= l && r <= tr){
seg[node] = max(seg[node], val);
return;
}
int mid = (l+r)/2;
upd(node*2, l, mid, tl, tr, val);
upd(node*2+1, mid+1, r, tl, tr, val);
}
void ispisi(int node, int l, int r){
if(l == r){
cout << seg[node]+l << " ";
return;
}
seg[node*2] = max(seg[node*2], seg[node]);
seg[node*2+1] = max(seg[node*2+1], seg[node]);
int mid = (l+r)/2;
ispisi(node*2, l, mid);
ispisi(node*2+1, mid+1, r);
}
void init(int node, int l, int r){
if(l == r){
seg[node] = -l;
return;
}
seg[node] = -1000000000;
int mid = (l+r)/2;
init(node*2, l, mid);
init(node*2+1, mid+1, r);
}
int main(){
ios_base::sync_with_stdio(false), cin.tie(0);
cout.precision(10);
cout << fixed;
int n, m;
cin >> n >> m;
init(1, 1, n);
for(int i=1; i<=m; i++){
int l, r, x;
cin >> l >> r >> x;
upd(1, 1, n, l, r, x-l);
}
ispisi(1, 1, n);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |