# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
882268 | alexdd | Trading (IZhO13_trading) | C++17 | 405 ms | 38460 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>
#include<vector>
#include<set>
using namespace std;
int n,m;
vector<pair<int,int>> inc[300005];
vector<pair<int,int>> sf[300005];
signed main()
{
cin>>n>>m;
int l,r,a;
for(int i=1;i<=m;i++)
{
cin>>l>>r>>a;
inc[l].push_back({a,r});
sf[r].push_back({a,l});
}
set<pair<int,pair<int,int>>> s;
for(int i=1;i<=n;i++)
{
for(auto x:inc[i])
{
s.insert({x.first - i, x});
}
if(s.empty())
{
cout<<0<<" ";
}
else
{
auto it = s.rbegin();
pair<int,pair<int,int>> cop = *it;
cout<<cop.first + i<<" ";
}
for(auto x:sf[i])
{
s.erase({x.first - x.second, {x.first,i}});
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |