#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int,int>
#define ret return
#define fr first
#define sc second
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define nosol puts("-1");
#define pb push_back
#define endi puts("");
#define ordered_set tree <int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N = 5e5+12,INF = 1e9+7;
int a[N],der[N];
main(){
int n,m,i;
cin>>n>>m;
deque <pair<pii,int> > v;
for (i=1;i<=m;++i){
int l,r,x;
cin>>l>>r>>x;
v.pb({{l,r},x-l});
}
priority_queue <pii> q;
sort(all(v));
for (i=1;i<=n;++i){
while (!v.empty() && v[0].fr.fr <= i){
q.push({v[0].sc,v[0].fr.sc});
v.pop_front();
}
while (!q.empty() && q.top().sc<i){
q.pop();
}
if (q.empty())cout <<0<<" ";
else
cout <<q.top().fr+i<< " ";
}
}
Compilation message
trading.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
22 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
460 KB |
Output is correct |
7 |
Correct |
171 ms |
8808 KB |
Output is correct |
8 |
Correct |
190 ms |
9644 KB |
Output is correct |
9 |
Correct |
206 ms |
10756 KB |
Output is correct |
10 |
Correct |
219 ms |
13016 KB |
Output is correct |
11 |
Correct |
225 ms |
11448 KB |
Output is correct |
12 |
Correct |
241 ms |
12452 KB |
Output is correct |
13 |
Correct |
288 ms |
12344 KB |
Output is correct |
14 |
Correct |
277 ms |
11636 KB |
Output is correct |
15 |
Correct |
292 ms |
15684 KB |
Output is correct |
16 |
Correct |
297 ms |
14156 KB |
Output is correct |
17 |
Correct |
283 ms |
14508 KB |
Output is correct |
18 |
Correct |
316 ms |
16648 KB |
Output is correct |
19 |
Correct |
311 ms |
14920 KB |
Output is correct |
20 |
Correct |
327 ms |
17196 KB |
Output is correct |