# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83710 | mra2322001 | Trading (IZhO13_trading) | C++14 | 287 ms | 7112 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, t[N*4];
void up(int k, int l, int r, int i, int j, int x){
if(r < i || l > j) return ;
if(l >= i && r <= j){
t[k] = max(t[k], l - i + x);
return ;
}
int m = (l + r)/2;
up(k*2, l, m, i, j, x);
up(k*2 + 1, m + 1, r, i, j, x);
}
int res= 0 ;
void get1(int k, int l, int r, int i){
if(l==r){
res = max(res, t[k]);
return ;
}
if(t[k]) res = max(res, t[k] + i - l);
int m = (l + r)/2;
if(i <= m) get1(k*2, l, m, i);
else get1(k*2 + 1, m + 1, r, i);
}
int main(){
ios_base::sync_with_stdio(0);
int q;
cin >> n >> q;
while(q--){
int l, r, x; cin >> l >> r >> x;
up(1, 1, n, l, r, x);
}
f1(i, n) {
res = 0;
get1(1, 1, n, i);
cout << res << " ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |