# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
495288 |
2021-12-18T08:41:06 Z |
reni |
Trading (IZhO13_trading) |
C++14 |
|
505 ms |
36516 KB |
#include<iostream>
#pragma GCC optimize ("O3")
#include<vector>
#include<set>
using namespace std;
multiset<long long>s;
vector<long long>v1[300002],v2[300002];
int main()
{
long long i,j,n,m,l,r,x;
cin>>n>>m;
for(i=1;i<=m;i++)
{
cin>>l>>r>>x;
v1[l].push_back(x-l);
v2[r].push_back(x-l);
}
for(i=1;i<=n;i++)
{
for(j=0;j<v1[i].size();j++)s.insert(v1[i][j]);
if(s.empty())
{
cout<<0<<" ";
}
else
{
auto it=s.end();it--;
cout<<*it+i<<" ";
}
for(j=0;j<v2[i].size();j++)s.erase(s.find(v2[i][j]));
}
cout<<endl;
}
Compilation message
trading.cpp: In function 'int main()':
trading.cpp:24:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(j=0;j<v1[i].size();j++)s.insert(v1[i][j]);
| ~^~~~~~~~~~~~~
trading.cpp:37:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for(j=0;j<v2[i].size();j++)s.erase(s.find(v2[i][j]));
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
14284 KB |
Output is correct |
2 |
Correct |
9 ms |
14364 KB |
Output is correct |
3 |
Correct |
11 ms |
14416 KB |
Output is correct |
4 |
Correct |
10 ms |
14416 KB |
Output is correct |
5 |
Correct |
11 ms |
14452 KB |
Output is correct |
6 |
Correct |
13 ms |
14528 KB |
Output is correct |
7 |
Correct |
239 ms |
26216 KB |
Output is correct |
8 |
Correct |
331 ms |
27236 KB |
Output is correct |
9 |
Correct |
277 ms |
27952 KB |
Output is correct |
10 |
Correct |
317 ms |
28884 KB |
Output is correct |
11 |
Correct |
303 ms |
29100 KB |
Output is correct |
12 |
Correct |
355 ms |
31660 KB |
Output is correct |
13 |
Correct |
340 ms |
30344 KB |
Output is correct |
14 |
Correct |
348 ms |
31868 KB |
Output is correct |
15 |
Correct |
401 ms |
32712 KB |
Output is correct |
16 |
Correct |
451 ms |
32864 KB |
Output is correct |
17 |
Correct |
394 ms |
33260 KB |
Output is correct |
18 |
Correct |
467 ms |
36084 KB |
Output is correct |
19 |
Correct |
430 ms |
33320 KB |
Output is correct |
20 |
Correct |
505 ms |
36516 KB |
Output is correct |