# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053081 | user736482 | Trading (IZhO13_trading) | C++17 | 104 ms | 14660 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<bits/stdc++.h>
using namespace std;
int n,m,l,r,x;
vector<pair<int,pair<int,int>>>v;
int odp[300007];
set<pair<int,int>,greater<pair<int,int>>>s;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
for(int i=0;i<m;i++){
cin>>l>>r>>x;
v.push_back({l,{x,r}});
}
sort(v.begin(),v.end());
int point=0;
for(int i=1;i<=n;i++){
//return 0;
while(point<v.size() && v[point].first==i){
s.insert({v[point].second.first-i,v[point].second.second});
point++;
}
//return 0;
if(s.empty())
s.insert({-i,i});
while((*s.begin()).second<i){
s.erase(s.begin());
if(s.empty())
s.insert({-i,i});
}
odp[i]=(*s.begin()).first+i;
cout<<odp[i]<<" ";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |