Submission #848425

#TimeUsernameProblemLanguageResultExecution timeMemory
848425Darren0724Trading (IZhO13_trading)C++17
100 / 100
308 ms26704 KiB
#include <bits/stdc++.h> using namespace std; struct info{ int c,l,r; }; int32_t main() { int n,m;cin>>n>>m; vector<info> v(m); set<int> s; for(int i=1;i<=n;i++){ s.insert(i); } for(int i=0;i<m;i++){ cin>>v[i].l>>v[i].r>>v[i].c; } sort(v.begin(),v.end(),[](info &a,info &b){return a.c-a.l>b.c-b.l;}); vector<int> ans(n+1); for(int i=0;i<m;i++){ auto it=s.lower_bound(v[i].l); while(it!=s.end()&&*it<=v[i].r){ ans[*it]=v[i].c+*it-v[i].l; s.erase(it); it=s.lower_bound(v[i].l); } } for(int i=1;i<=n;i++){ cout<<ans[i]<<' '; } cout<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...