Submission #13107

#TimeUsernameProblemLanguageResultExecution timeMemory
13107dohyun0324Trading (IZhO13_trading)C++98
0 / 100
332 ms16432 KiB
#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(a[j].r>=i) break; q.erase(a[j].x-a[j].l); } p2=j; if(q.empty()){printf("0 "); continue;} p=q.end(); p--; printf("%d ",(*p)+i); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...