# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495288 | reni | Trading (IZhO13_trading) | C++14 | 505 ms | 36516 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |