# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
848425 | Darren0724 | Trading (IZhO13_trading) | C++17 | 308 ms | 26704 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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |