# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41318 | IvanC | Trading (IZhO13_trading) | C++14 | 239 ms | 65536 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;
typedef pair<int,int> ii;
typedef tuple<int,int,int> trinca;
priority_queue<ii> pq;
vector<trinca> sweep;
int N,M,ptr;
int main(){
scanf("%d %d",&N,&M);
for(int i = 1;i<=M;i++){
int l,r,x;
scanf("%d %d %d",&l,&r,&x);
sweep.push_back(make_tuple(l,x - l,r));
}
sort(sweep.begin(),sweep.end());
for(int i = 1;i<=N;i++){
while(ptr < M && get<0>(sweep[ptr]) <= i ){
ii novo = ii(get<1>(sweep[ptr]),get<2>(sweep[ptr]));
pq.push(novo);
ptr++;
}
while(!pq.empty() && pq.top().second < i ){
pq.pop();
}
if(!pq.empty()){
printf("%d ",pq.top().first + i);
}
else{
printf("0 ");
}
}
printf("\n");
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |