#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"
using ll = long long;
const int MAX_N = 3e5;
vector <int> to_add[1 + MAX_N], to_erase[1 + MAX_N + 1];
int main () {
ios::sync_with_stdio (false);
cin.tie (0); cout.tie (0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int l, r, x;
cin >> l >> r >> x;
to_add[l].pb (x - l);
to_erase[r + 1].pb (x - l);
}
multiset <int> hat_prices;
for (int i = 1; i <= n; i++) {
for (int x : to_add[i])
hat_prices.insert (x);
for (int x : to_erase[i])
hat_prices.erase (hat_prices.find (x));
if (hat_prices.size () == 0)
cout << "0 ";
else
cout << *prev (hat_prices.end ()) + i << " ";
}
cout << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
10 ms |
14444 KB |
Output is correct |
4 |
Correct |
10 ms |
14444 KB |
Output is correct |
5 |
Correct |
11 ms |
14572 KB |
Output is correct |
6 |
Correct |
11 ms |
14572 KB |
Output is correct |
7 |
Correct |
169 ms |
25700 KB |
Output is correct |
8 |
Correct |
191 ms |
26724 KB |
Output is correct |
9 |
Correct |
198 ms |
26980 KB |
Output is correct |
10 |
Correct |
219 ms |
27876 KB |
Output is correct |
11 |
Correct |
225 ms |
28516 KB |
Output is correct |
12 |
Correct |
251 ms |
30432 KB |
Output is correct |
13 |
Correct |
246 ms |
29664 KB |
Output is correct |
14 |
Correct |
261 ms |
30688 KB |
Output is correct |
15 |
Correct |
291 ms |
31588 KB |
Output is correct |
16 |
Correct |
336 ms |
32044 KB |
Output is correct |
17 |
Correct |
300 ms |
32352 KB |
Output is correct |
18 |
Correct |
332 ms |
35168 KB |
Output is correct |
19 |
Correct |
318 ms |
32352 KB |
Output is correct |
20 |
Correct |
359 ms |
35420 KB |
Output is correct |