Submission #1211338

#TimeUsernameProblemLanguageResultExecution timeMemory
1211338PlayVoltzTrading (IZhO13_trading)C++20
100 / 100
260 ms39320 KiB
#include <cstdio>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <cassert>
#include <chrono>
using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second

struct node{
	int s, e, m, val;
	node *l, *r;
	void create(){
		if (l==nullptr){
			l = new node(s, m);
			r = new node(m+1, e);
		}
	}
	node(int S, int E){
		s = S, e = E, m = (s+e)/2;
		val=LLONG_MIN/2;
		l=r=nullptr;
	}
	void up(int left, int right, int v){
		if (left<=s && e<=right)val=max(val, v);
		else{
			create();
			if (s<=right&&left<=m)l->up(left, right, v);
			if (right>m&&left<=e)r->up(left, right, v);
		}
	}
	int query(int i){
		if (s==e)return val;
		create();
		if (i<=m)return max(val, l->query(i));
		return max(val, r->query(i));
	}
}*st;

int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, q, a, b, c;
	cin>>n>>q;
	st = new node(1, n);
	while (q--){
		cin>>a>>b>>c;
		st->up(a, b, c-a);
	}
	for (int i=1; i<=n; ++i)cout<<max(0ll, st->query(i)+i)<<" ";
}
#Verdict Execution timeMemoryGrader output
Fetching results...