#include "bits/stdc++.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
using ll = long long;
const int mod = 1e9+7;
void solve(int tc) {
int n, m;
cin >> n >> m;
vector<vector<int>> in(n), out(n);
while (m--) {
int l, r, x;
cin >> l >> r >> x;
--l, --r;
in[l].push_back(x-l);
out[r].push_back(x-l);
}
multiset<int> ms;
for (int i = 0; i < n; ++i) {
for (int x : in[i]) ms.insert(x);
cout << (ms.empty() ? 0 : *ms.rbegin() + i) << " ";
for (int x : out[i]) ms.erase(ms.find(x));
}
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int tc = 1;
//cin >> tc;
for (int i = 1; i <= tc; ++i) solve(i);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
3 ms |
620 KB |
Output is correct |
7 |
Correct |
177 ms |
18660 KB |
Output is correct |
8 |
Correct |
200 ms |
20580 KB |
Output is correct |
9 |
Correct |
215 ms |
20964 KB |
Output is correct |
10 |
Correct |
216 ms |
22756 KB |
Output is correct |
11 |
Correct |
245 ms |
24284 KB |
Output is correct |
12 |
Correct |
268 ms |
26208 KB |
Output is correct |
13 |
Correct |
260 ms |
26376 KB |
Output is correct |
14 |
Correct |
301 ms |
27872 KB |
Output is correct |
15 |
Correct |
331 ms |
29388 KB |
Output is correct |
16 |
Correct |
334 ms |
29796 KB |
Output is correct |
17 |
Correct |
329 ms |
30628 KB |
Output is correct |
18 |
Correct |
346 ms |
33824 KB |
Output is correct |
19 |
Correct |
367 ms |
31840 KB |
Output is correct |
20 |
Correct |
406 ms |
35528 KB |
Output is correct |