#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll
const int N = 3e5 + 5;
const int INF = 1e9 + 5;
int n, m, ans[N];
vector <int> add[N], del[N];
multiset <int> st;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for(int i = 1; i <= m; ++i) {
int l, r, x;
cin >> l >> r >> x;
add[l].pb(x - l);
del[r].pb(x - l);
}
for(int i = 1; i <= n; ++i) {
for(int it : add[i]) {
st.insert(it);
}
if(sz(st)) {
ans[i] = *st.rbegin() + i;
} else {
ans[i] = 0;
}
for(int it : del[i]) {
st.erase(st.find(it));
}
}
for(int i = 1; i <= n; ++i) {
cout << ans[i] <<' ';
}
return 0;
}
/*
If you only do what you can do,
You will never be more than you are now!
----------------------------------------------------------
We must all suffer from one of two pains: the pain of discipline or the pain of regret.
The difference is discipline weighs grams while regret weighs tons.
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
14584 KB |
Output is correct |
2 |
Correct |
14 ms |
14456 KB |
Output is correct |
3 |
Correct |
15 ms |
14456 KB |
Output is correct |
4 |
Correct |
15 ms |
14584 KB |
Output is correct |
5 |
Correct |
16 ms |
14584 KB |
Output is correct |
6 |
Correct |
17 ms |
14712 KB |
Output is correct |
7 |
Correct |
203 ms |
26352 KB |
Output is correct |
8 |
Correct |
222 ms |
27440 KB |
Output is correct |
9 |
Correct |
226 ms |
27692 KB |
Output is correct |
10 |
Correct |
256 ms |
28860 KB |
Output is correct |
11 |
Correct |
253 ms |
29352 KB |
Output is correct |
12 |
Correct |
287 ms |
31340 KB |
Output is correct |
13 |
Correct |
294 ms |
30572 KB |
Output is correct |
14 |
Correct |
304 ms |
31700 KB |
Output is correct |
15 |
Correct |
339 ms |
32624 KB |
Output is correct |
16 |
Correct |
376 ms |
32880 KB |
Output is correct |
17 |
Correct |
373 ms |
33416 KB |
Output is correct |
18 |
Correct |
384 ms |
36332 KB |
Output is correct |
19 |
Correct |
361 ms |
33648 KB |
Output is correct |
20 |
Correct |
438 ms |
36772 KB |
Output is correct |