#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, m;
multiset<int> mts;
int a[N];
vector<array<int, 3>> e;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int l, r, x;
cin >> l >> r >> x;
e.push_back(array<int, 3>{l, x - l, 0});
e.push_back(array<int, 3>{r + 1, x - l, 1});
}
memset(a, -0x3f, sizeof(a));
sort(e.begin(), e.end());
for (int i = 1, j = 0; i <= n; i++) {
while (j < (int) e.size() && e[j][0] <= i) {
if (e[j][2] == 0) {
mts.insert(e[j][1]);
} else {
mts.erase(mts.find(e[j][1]));
}
j++;
}
if (mts.empty()) {
cout << 0 << ' ';
} else {
cout << *mts.rbegin() + i << ' ';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1624 KB |
Output is correct |
2 |
Correct |
1 ms |
1780 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
2 ms |
1628 KB |
Output is correct |
5 |
Correct |
2 ms |
1752 KB |
Output is correct |
6 |
Correct |
2 ms |
1628 KB |
Output is correct |
7 |
Correct |
96 ms |
11640 KB |
Output is correct |
8 |
Correct |
106 ms |
13420 KB |
Output is correct |
9 |
Correct |
110 ms |
14968 KB |
Output is correct |
10 |
Correct |
124 ms |
15408 KB |
Output is correct |
11 |
Correct |
117 ms |
13320 KB |
Output is correct |
12 |
Correct |
159 ms |
17596 KB |
Output is correct |
13 |
Correct |
136 ms |
15744 KB |
Output is correct |
14 |
Correct |
143 ms |
16800 KB |
Output is correct |
15 |
Correct |
168 ms |
17724 KB |
Output is correct |
16 |
Correct |
168 ms |
16816 KB |
Output is correct |
17 |
Correct |
172 ms |
18000 KB |
Output is correct |
18 |
Correct |
172 ms |
22700 KB |
Output is correct |
19 |
Correct |
165 ms |
18160 KB |
Output is correct |
20 |
Correct |
202 ms |
21724 KB |
Output is correct |