#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const ll NMAX = 300002;
const ll INF = (1LL << 60);
const ll nrbits = 20;
const ll MOD = 998244353;
const ll bucket = 320;
const double eps = 0.00000001;
struct ura{
int l, r, x, bgt;
}qq[NMAX];
multiset <int> st;
vector <int> events[NMAX];
signed main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m, i;
cin >> n >> m;
for(i = 1; i <= m; i++){
int a, b, c;
cin >> a >> b >> c;
qq[i] = {a, b, c};
events[a].push_back(i);
events[b + 1].push_back(-i);
}
int offset = 0;
for(i = 1; i <= n; i++){
offset++;
for(auto x : events[i]){
if(x < 0){
st.erase(st.find(qq[-x].bgt));
}else{
st.insert(qq[x].x - offset);
qq[x].bgt = qq[x].x - offset;
}
}
if(st.size() == 0){
cout << 0 << " ";
continue;
}
auto it = prev(st.end());
cout << (*it) + offset << " ";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8844 KB |
Output is correct |
2 |
Correct |
2 ms |
8796 KB |
Output is correct |
3 |
Correct |
2 ms |
8796 KB |
Output is correct |
4 |
Correct |
2 ms |
8796 KB |
Output is correct |
5 |
Correct |
2 ms |
8796 KB |
Output is correct |
6 |
Correct |
3 ms |
8796 KB |
Output is correct |
7 |
Correct |
92 ms |
20300 KB |
Output is correct |
8 |
Correct |
108 ms |
22088 KB |
Output is correct |
9 |
Correct |
119 ms |
22548 KB |
Output is correct |
10 |
Correct |
127 ms |
23096 KB |
Output is correct |
11 |
Correct |
132 ms |
24348 KB |
Output is correct |
12 |
Correct |
146 ms |
26052 KB |
Output is correct |
13 |
Correct |
141 ms |
24564 KB |
Output is correct |
14 |
Correct |
183 ms |
25052 KB |
Output is correct |
15 |
Correct |
183 ms |
27164 KB |
Output is correct |
16 |
Correct |
196 ms |
26072 KB |
Output is correct |
17 |
Correct |
197 ms |
27172 KB |
Output is correct |
18 |
Correct |
258 ms |
31172 KB |
Output is correct |
19 |
Correct |
184 ms |
27352 KB |
Output is correct |
20 |
Correct |
255 ms |
30528 KB |
Output is correct |