# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
5399 | gs12117 | Trading (IZhO13_trading) | C++98 | 168 ms | 7532 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<stdio.h>
#include<algorithm>
int n,m;
struct trader{
int l,r,p;
bool operator<(const trader&v)const{
return p>v.p;
}
};
trader tset[300100];
int ans[300100];
int uft[300100];
int uftf(int x){
if(x==uft[x])return x;
return uft[x]=uftf(uft[x]);
}
int main(){
int i,j;
scanf("%d%d",&n,&m);
for(i=0;i<m;i++){
scanf("%d%d%d",&tset[i].l,&tset[i].r,&tset[i].p);
tset[i].l--;
tset[i].p-=tset[i].l;
}
std::sort(tset,tset+m);
for(i=0;i<=n;i++){
uft[i]=i;
}
for(i=0;i<m;i++){
for(j=uftf(tset[i].l);j<tset[i].r;j=uftf(j)){
ans[j]=tset[i].p+j;
uft[j]=uftf(j+1);
}
}
for(i=0;i<n;i++){
printf("%d ",ans[i]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |