# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
21856 | 2017-04-26T13:19:43 Z | ulna | Trading (IZhO13_trading) | C++11 | 216 ms | 4364 KB |
#include <bits/stdc++.h> using namespace std; // why am I so weak int n, m; int dat[600055]; void update(int l, int r, int val) { l += n, r += n; for (; l < r; l >>= 1, r >>= 1) { if (l & 1) { dat[l] = max(dat[l], val); l++; } if (r & 1) { r--; dat[r] = max(dat[r], val); } } } int query(int id) { int res = -INT_MAX; for (id += n; id > 0; id >>= 1) { res = max(res, dat[id]); } return res; } int main() { scanf("%d %d", &n, &m); for (int i = 0; i < n + n; i++) { dat[i] = -INT_MAX; } while (m--) { int x, y, z; scanf("%d %d %d", &x, &y, &z); x--; update(x, y, z - x); } for (int i = 0; i < n; i++) { if (i) printf(" "); int res = query(i); if (res == -INT_MAX) res = 0; else res += i; printf("%d", res); } puts(""); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4364 KB | Output is correct |
2 | Correct | 0 ms | 4364 KB | Output is correct |
3 | Correct | 0 ms | 4364 KB | Output is correct |
4 | Correct | 0 ms | 4364 KB | Output is correct |
5 | Correct | 0 ms | 4364 KB | Output is correct |
6 | Correct | 0 ms | 4364 KB | Output is correct |
7 | Correct | 103 ms | 4364 KB | Output is correct |
8 | Correct | 109 ms | 4364 KB | Output is correct |
9 | Correct | 129 ms | 4364 KB | Output is correct |
10 | Correct | 119 ms | 4364 KB | Output is correct |
11 | Correct | 149 ms | 4364 KB | Output is correct |
12 | Correct | 146 ms | 4364 KB | Output is correct |
13 | Correct | 159 ms | 4364 KB | Output is correct |
14 | Correct | 159 ms | 4364 KB | Output is correct |
15 | Correct | 186 ms | 4364 KB | Output is correct |
16 | Correct | 183 ms | 4364 KB | Output is correct |
17 | Correct | 179 ms | 4364 KB | Output is correct |
18 | Correct | 166 ms | 4364 KB | Output is correct |
19 | Correct | 169 ms | 4364 KB | Output is correct |
20 | Correct | 216 ms | 4364 KB | Output is correct |