제출 #249735

#제출 시각아이디문제언어결과실행 시간메모리
249735srvlt거래 (IZhO13_trading)C++14
0 / 100
15 ms14848 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 3e5 + 123;
int n, m;
vector <int> q[n0];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int l, r, x;
		cin >> l >> r >> x;
		q[l].pb(-(x - l)), q[r + 1].pb(x - l);
	}
	multiset <int> st;
	for (int i = 1; i <= n; i++) {
		sort(all(q[i]));
		for (int j : q[i]) {
			if (j < 0) st.insert(-j);
			else st.erase(st.find(j));
		}
		if (st.empty()) cout << 0 << ' ';
		else cout << *(--st.end()) + i << ' ';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...