# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314276 | 2020-10-19T10:44:36 Z | BeanZ | Trading (IZhO13_trading) | C++14 | 201 ms | 13924 KB |
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 3e5 + 5; struct viet{ ll l, r, x; bool operator <(const viet &o) const{ return l < o.l; } }a[N]; struct lpl{ ll l, r, x; bool operator <(const lpl &o) const{ return (l - x) > (o.l - o.x); } }; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("A.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n, m; cin >> n >> m; for (int i = 1; i <= m; i++){ cin >> a[i].l >> a[i].r >> a[i].x; } sort(a + 1, a + m + 1); ll now = 1; priority_queue<lpl> pq; for (int i = 1; i <= n; i++){ while (now <= m && a[now].l == i){ lpl x = {a[now].l, a[now].r, a[now].x}; pq.push(x); now++; } while (pq.size()){ if (pq.top().r < i) pq.pop(); else break; } if (pq.size() == 0) cout << 0 << " "; else { cout << i - pq.top().l + pq.top().x << " "; } } } /* */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 512 KB | Output is correct |
6 | Correct | 2 ms | 640 KB | Output is correct |
7 | Correct | 100 ms | 6524 KB | Output is correct |
8 | Correct | 107 ms | 7016 KB | Output is correct |
9 | Correct | 118 ms | 8468 KB | Output is correct |
10 | Correct | 130 ms | 11496 KB | Output is correct |
11 | Correct | 122 ms | 8812 KB | Output is correct |
12 | Correct | 146 ms | 12520 KB | Output is correct |
13 | Correct | 142 ms | 8940 KB | Output is correct |
14 | Correct | 146 ms | 9784 KB | Output is correct |
15 | Correct | 172 ms | 13032 KB | Output is correct |
16 | Correct | 171 ms | 10220 KB | Output is correct |
17 | Correct | 167 ms | 10208 KB | Output is correct |
18 | Correct | 182 ms | 13416 KB | Output is correct |
19 | Correct | 176 ms | 13924 KB | Output is correct |
20 | Correct | 201 ms | 12132 KB | Output is correct |