# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
13115 | dohyun0324 | Trading (IZhO13_trading) | C++98 | 629 ms | 24088 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>
#include<map>
using namespace std;
set<int>q;
map<int,int>ch;
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;
ch[a[j].x-a[j].l]++;
q.insert(a[j].x-a[j].l);
}
p1=j;
for(j=p2;j<=m;j++){
if(b[j].r>=i) break;
ch[b[j].x-b[j].l]--;
if(ch[b[j].x-b[j].l]==0) 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... |