Submission #684528

# Submission time Handle Problem Language Result Execution time Memory
684528 2023-01-21T13:24:40 Z NintsiChkhaidze Trading (IZhO13_trading) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
#define ll long long
#define left (h<<1),l,((l+r)>>1)
#define right ((h<<1)|1),((l+r)>>1) + 1,r
#define pb push_back
#define s second
#define f first
#define pii pair<int,int>
#define int ll
using namespace std;

const int N = 300005,inf = -1e18;
int t[4*N],lz[4*N];

void push(int h){
    if (!lz[h]) return;
    lz[h*2]=max(lz[h*2],lz[h]);
    lz[h*2+1]=max(lz[h*2+1],lz[h]);

    t[h*2]=max(t[h*2],lz[h]);
    t[h*2+1]=max(t[h*2+1],lz[h]);
}
void upd(int h,int l,int r,int L,int R,int x){
    if (r < L || R < l) return;
    if (L <= l && r <= R){
        t[h] = max(t[h],x);
        lz[h] = x;
        return;
    }
    push(h);
    upd(left,L,R,x);
    upd(right,L,R,x);
    t[h] = max(t[h*2],t[h*2+1]);
}

int get(int h,int l,int r,int idx){
    if (l == r) {
        return t[h];
    }
    push(h);
    if (idx > (l + r)>>1) return get(right,idx);
    else return get(left,idx);
}
void build(int h,int l,int r){
    t[h] = inf;
    if (l==r) return ;
    build(left),build(right);
}
signed main (){
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    
    int n,q;
    cin>>n>>q;

    build(1,1,n);
    while (q--){
        int l,r,x;
        cin>>l>>r>>x;
        upd(1,1,n,l,r,x-l);
    }

    for (int i = 1; i <= n; i++){
        int p = get(1,1,n,i);
        if (p == inf) cout<<0<<" "; 
        else cout<<p + i<<" ";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -