#include <bits/stdc++.h>
#define ll long long
#define s second
#define f first
using namespace std;
ll n,a[300005],sum,x,k,ans,t,ans1,y,z,u,m;
bool ok;
vector <ll> l[300005],r[300005];
multiset <ll> s;
int main(){
ios :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n>>m;
for (int o=1; o<=m; o++){
cin>>y>>z>>x;
l[y].push_back(x-y+1);
r[z].push_back(x-y+1);
}
for (int i=1; i<=n; i++){
for (int j=0; j<l[i].size(); j++){
s.insert(l[i][j]);
}
if (s.size()==0) {
cout<<0<<" ";
continue;
}
set <ll> ::iterator it = s.end();
it--;
cout<<(*it)+i-1<<" ";
for (int j=0; j<r[i].size(); j++){
s.erase(s.find(r[i][j]));
}
}
cout<<endl;
}
Compilation message
trading.cpp: In function 'int main()':
trading.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for (int j=0; j<l[i].size(); j++){
| ~^~~~~~~~~~~~
trading.cpp:32:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int j=0; j<r[i].size(); j++){
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14292 KB |
Output is correct |
2 |
Correct |
7 ms |
14292 KB |
Output is correct |
3 |
Correct |
8 ms |
14388 KB |
Output is correct |
4 |
Correct |
8 ms |
14420 KB |
Output is correct |
5 |
Correct |
8 ms |
14448 KB |
Output is correct |
6 |
Correct |
9 ms |
14504 KB |
Output is correct |
7 |
Correct |
127 ms |
23368 KB |
Output is correct |
8 |
Correct |
175 ms |
24204 KB |
Output is correct |
9 |
Correct |
157 ms |
24540 KB |
Output is correct |
10 |
Correct |
173 ms |
25304 KB |
Output is correct |
11 |
Correct |
189 ms |
25488 KB |
Output is correct |
12 |
Correct |
228 ms |
27492 KB |
Output is correct |
13 |
Correct |
204 ms |
26160 KB |
Output is correct |
14 |
Correct |
197 ms |
27612 KB |
Output is correct |
15 |
Correct |
223 ms |
27884 KB |
Output is correct |
16 |
Correct |
256 ms |
27772 KB |
Output is correct |
17 |
Correct |
232 ms |
28204 KB |
Output is correct |
18 |
Correct |
297 ms |
30888 KB |
Output is correct |
19 |
Correct |
254 ms |
28424 KB |
Output is correct |
20 |
Correct |
330 ms |
30576 KB |
Output is correct |