# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89387 | turbat | Trading (IZhO13_trading) | C++14 | 503 ms | 40632 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;
#define N 300005
int n, m, l, r, x, seg[4 * N], ans[N];
void update(int node, int L, int R, int l, int r){
if (L > r || l > R) return;
if (l <= L && r >= R){
seg[node] = max(seg[node], x);
return;
}
int mid = (L + R)/2;
update(node * 2, L, mid, l, r);
update(node * 2 + 1, mid + 1, R, l, r);
}
void res(int node, int l, int r){
if (l == r){
ans[l] = seg[node];
return;
}
int mid = (l + r)/2;
seg[node * 2] = max(seg[node], seg[node * 2]);
res(node * 2, l, mid);
seg[node * 2 + 1] = max(seg[node], seg[node * 2 + 1]);
res(node * 2 + 1, mid + 1, r);
}
int main (){
cin >> n>> m;
for (int i = 0;i < 4 * n;i++) seg[i] = -1e9;
while (m--){
cin >> l>> r>> x;
x -= (l - 1);
update(1, 1, n, l, r);
}
res(1, 1, n);
for (int i = 0;i < n;i++)
cout << max(ans[i + 1] + i, 0)<<" ";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |