# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339818 | beksultan04 | Trading (IZhO13_trading) | C++14 | 223 ms | 18016 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;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
const int N = 1e5+12,INF=1e9+7;
main(){
int n,m,i;
scan2(n,m)
deque <pair<pii,int> > v;
while (m--){
int l,r,x;
scan3(l,r,x)
v.pb({{l,r},x-l});
}
sort(all(v));
priority_queue <pair<int,pii> > q;
int h=0;
for (i=1;i<=n;++i){
while (!v.empty() && v[0].fr.fr <= i){
q.push({v[0].sc,{-v[0].fr.fr,v[0].fr.sc}});
v.pop_front();
}
pair <int,pii> p ;
if (q.empty())
p = {0,{-i,0}};
else
p = q.top();
while (!q.empty() && p.sc.sc < i){
q.pop();
if (q.empty())
p = {0,{-i,0}};
else
p = q.top();
}
if (p.fr == 0)p.fr = -i;
cout <<p.fr+i<<" ";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |