#include <bits/stdc++.h>
// author : aykhn
using namespace std;
typedef long long ll;
#define pb push_back
#define ins insert
#define mpr make_pair
#define all(v) v.begin(), v.end()
#define bpc __builtin_popcount
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define int ll
#define infll 0x3F3F3F3F3F3F3F3F
#define inf 0x3F3F3F3F
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<multiset<int>> v1(n + 1);
vector<multiset<int>> v2(n + 2);
while (m--)
{
int l, r, x;
cin >> l >> r >> x;
v1[l].ins(x - l);
v2[r + 1].ins(x - l);
}
multiset<int> ms;
for (int i = 1; i <= n; i++)
{
for (int x : v2[i]) ms.erase(ms.lower_bound(x));
for (int x : v1[i]) ms.ins(x);
if (!ms.empty()) cout << *ms.rbegin() + i << " ";
else cout << 0 << " ";
}
cout << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
556 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
860 KB |
Output is correct |
7 |
Correct |
153 ms |
32072 KB |
Output is correct |
8 |
Correct |
178 ms |
34900 KB |
Output is correct |
9 |
Correct |
181 ms |
37052 KB |
Output is correct |
10 |
Correct |
224 ms |
41812 KB |
Output is correct |
11 |
Correct |
196 ms |
40904 KB |
Output is correct |
12 |
Correct |
269 ms |
47288 KB |
Output is correct |
13 |
Correct |
272 ms |
46564 KB |
Output is correct |
14 |
Correct |
256 ms |
49232 KB |
Output is correct |
15 |
Correct |
313 ms |
52540 KB |
Output is correct |
16 |
Correct |
312 ms |
53140 KB |
Output is correct |
17 |
Correct |
303 ms |
54120 KB |
Output is correct |
18 |
Correct |
326 ms |
58460 KB |
Output is correct |
19 |
Correct |
328 ms |
57260 KB |
Output is correct |
20 |
Correct |
371 ms |
64152 KB |
Output is correct |