# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
339818 | 2020-12-26T09:20:27 Z | beksultan04 | Trading (IZhO13_trading) | C++14 | 223 ms | 18016 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 2 ms | 492 KB | Output is correct |
6 | Correct | 2 ms | 620 KB | Output is correct |
7 | Correct | 111 ms | 7648 KB | Output is correct |
8 | Correct | 122 ms | 8420 KB | Output is correct |
9 | Correct | 133 ms | 11740 KB | Output is correct |
10 | Correct | 141 ms | 15072 KB | Output is correct |
11 | Correct | 146 ms | 12404 KB | Output is correct |
12 | Correct | 162 ms | 16476 KB | Output is correct |
13 | Correct | 162 ms | 12896 KB | Output is correct |
14 | Correct | 166 ms | 12128 KB | Output is correct |
15 | Correct | 188 ms | 17116 KB | Output is correct |
16 | Correct | 199 ms | 14308 KB | Output is correct |
17 | Correct | 189 ms | 14304 KB | Output is correct |
18 | Correct | 204 ms | 17500 KB | Output is correct |
19 | Correct | 208 ms | 18016 KB | Output is correct |
20 | Correct | 223 ms | 16172 KB | Output is correct |