# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
13111 | dohyun0324 | Trading (IZhO13_trading) | C++98 | 349 ms | 14452 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>
#include<set>
using namespace std;
set<int>q;
int n,m;
struct data{
int l,r,x;
bool operator<(const data&r)const{
return l<r.l;
}
}a[300010];
struct data2{
int l,r,x;
bool operator<(const data2&p)const{
return r<p.r;
}
}b[300010];
int main()
{
int i,j,p1=1,p2=1;
set<int>::iterator p;
scanf("%d %d",&n,&m);
for(i=1;i<=m;i++)
{
scanf("%d %d %d",&a[i].l,&a[i].r,&a[i].x);
b[i].l=a[i].l; b[i].r=a[i].r; b[i].x=a[i].x;
}
sort(a+1,a+m+1);
sort(b+1,b+m+1);
for(i=1;i<=n;i++){
for(j=p1;j<=m;j++){
if(a[j].l>i) break;
q.insert(a[j].x-a[j].l);
}
p1=j;
for(j=p2;j<=m;j++){
if(b[j].r>=i) break;
q.erase(b[j].x-b[j].l);
}
p2=j;
if(q.empty()){printf("0 "); continue;}
p=q.end(); p--;
printf("%d ",(*p)+i);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |