# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
474215 | 2021-09-17T11:41:03 Z | nonsensenonsense1 | New Home (APIO18_new_home) | C++17 | 5000 ms | 46552 KB |
#include <cstdio> #include <set> #include <algorithm> const int N = 300000; struct data { int x, t, tm; bool open; bool operator<(data arg) { return tm < arg.tm; } } s[N << 1]; struct query { int x, tm, ind; bool operator<(query arg) { return tm < arg.tm; } } q[N]; int n, k, m, size, ans[N]; std::multiset<int> cur[N]; int main() { scanf("%d%d%d", &n, &k, &m); for (int i = 0; i < n; ++i) { scanf("%d%d%d%d", &s[i << 1].x, &s[i << 1].t, &s[i << 1].tm, &s[i << 1 | 1].tm); s[i << 1 | 1].x = s[i << 1].x; s[i << 1 | 1].t = --s[i << 1].t; s[i << 1].open = true; s[i << 1 | 1].open = false; --s[i << 1].tm; } std::sort(s, s + (n << 1)); for (int i = 0; i < m; ++i) { scanf("%d%d", &q[i].x, &q[i].tm); q[i].ind = i; --q[i].tm; } std::sort(q, q + m); std::multiset<int>::iterator it; for (int i = 0, j = 0; i < m; ++i) { while (j < n << 1 && s[j].tm <= q[i].tm) { if (s[j].open) cur[s[j].t].insert(s[j].x); else cur[s[j].t].erase(cur[s[j].t].find(s[j].x)); ++j; } for (int j = 0; j < k; ++j) { it = cur[j].lower_bound(q[i].x); int dist = ~(1 << 31); if (it != cur[j].end()) dist = std::min(dist, *it - q[i].x); if (it != cur[j].begin()) dist = std::min(dist, q[i].x - *prev(it)); ans[q[i].ind] = std::max(ans[q[i].ind], dist); } } for (int i = 0; i < m; ++i) { if (ans[i] == ~(1 << 31)) printf("-1\n"); else printf("%d\n", ans[i]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 14284 KB | Output is correct |
2 | Correct | 9 ms | 14376 KB | Output is correct |
3 | Correct | 8 ms | 14284 KB | Output is correct |
4 | Correct | 8 ms | 14284 KB | Output is correct |
5 | Correct | 9 ms | 14364 KB | Output is correct |
6 | Correct | 9 ms | 14412 KB | Output is correct |
7 | Correct | 12 ms | 14388 KB | Output is correct |
8 | Correct | 10 ms | 14412 KB | Output is correct |
9 | Correct | 12 ms | 14412 KB | Output is correct |
10 | Correct | 10 ms | 14388 KB | Output is correct |
11 | Correct | 9 ms | 14392 KB | Output is correct |
12 | Correct | 9 ms | 14388 KB | Output is correct |
13 | Correct | 8 ms | 14388 KB | Output is correct |
14 | Correct | 9 ms | 14340 KB | Output is correct |
15 | Correct | 9 ms | 14412 KB | Output is correct |
16 | Correct | 9 ms | 14348 KB | Output is correct |
17 | Correct | 9 ms | 14384 KB | Output is correct |
18 | Correct | 9 ms | 14388 KB | Output is correct |
19 | Correct | 10 ms | 14412 KB | Output is correct |
20 | Correct | 9 ms | 14412 KB | Output is correct |
21 | Correct | 9 ms | 14388 KB | Output is correct |
22 | Correct | 10 ms | 14440 KB | Output is correct |
23 | Correct | 9 ms | 14412 KB | Output is correct |
24 | Correct | 10 ms | 14392 KB | Output is correct |
25 | Correct | 11 ms | 14416 KB | Output is correct |
26 | Correct | 10 ms | 14412 KB | Output is correct |
27 | Correct | 10 ms | 14360 KB | Output is correct |
28 | Correct | 10 ms | 14304 KB | Output is correct |
29 | Correct | 10 ms | 14408 KB | Output is correct |
30 | Correct | 10 ms | 14412 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 14284 KB | Output is correct |
2 | Correct | 9 ms | 14376 KB | Output is correct |
3 | Correct | 8 ms | 14284 KB | Output is correct |
4 | Correct | 8 ms | 14284 KB | Output is correct |
5 | Correct | 9 ms | 14364 KB | Output is correct |
6 | Correct | 9 ms | 14412 KB | Output is correct |
7 | Correct | 12 ms | 14388 KB | Output is correct |
8 | Correct | 10 ms | 14412 KB | Output is correct |
9 | Correct | 12 ms | 14412 KB | Output is correct |
10 | Correct | 10 ms | 14388 KB | Output is correct |
11 | Correct | 9 ms | 14392 KB | Output is correct |
12 | Correct | 9 ms | 14388 KB | Output is correct |
13 | Correct | 8 ms | 14388 KB | Output is correct |
14 | Correct | 9 ms | 14340 KB | Output is correct |
15 | Correct | 9 ms | 14412 KB | Output is correct |
16 | Correct | 9 ms | 14348 KB | Output is correct |
17 | Correct | 9 ms | 14384 KB | Output is correct |
18 | Correct | 9 ms | 14388 KB | Output is correct |
19 | Correct | 10 ms | 14412 KB | Output is correct |
20 | Correct | 9 ms | 14412 KB | Output is correct |
21 | Correct | 9 ms | 14388 KB | Output is correct |
22 | Correct | 10 ms | 14440 KB | Output is correct |
23 | Correct | 9 ms | 14412 KB | Output is correct |
24 | Correct | 10 ms | 14392 KB | Output is correct |
25 | Correct | 11 ms | 14416 KB | Output is correct |
26 | Correct | 10 ms | 14412 KB | Output is correct |
27 | Correct | 10 ms | 14360 KB | Output is correct |
28 | Correct | 10 ms | 14304 KB | Output is correct |
29 | Correct | 10 ms | 14408 KB | Output is correct |
30 | Correct | 10 ms | 14412 KB | Output is correct |
31 | Correct | 2262 ms | 23336 KB | Output is correct |
32 | Correct | 118 ms | 19316 KB | Output is correct |
33 | Correct | 189 ms | 21348 KB | Output is correct |
34 | Correct | 1772 ms | 21572 KB | Output is correct |
35 | Correct | 1020 ms | 23256 KB | Output is correct |
36 | Correct | 242 ms | 23128 KB | Output is correct |
37 | Correct | 187 ms | 20700 KB | Output is correct |
38 | Correct | 122 ms | 20548 KB | Output is correct |
39 | Correct | 107 ms | 20300 KB | Output is correct |
40 | Correct | 97 ms | 20308 KB | Output is correct |
41 | Correct | 307 ms | 20656 KB | Output is correct |
42 | Correct | 385 ms | 20476 KB | Output is correct |
43 | Correct | 367 ms | 22792 KB | Output is correct |
44 | Correct | 249 ms | 20668 KB | Output is correct |
45 | Correct | 128 ms | 20596 KB | Output is correct |
46 | Correct | 83 ms | 20660 KB | Output is correct |
47 | Correct | 79 ms | 20148 KB | Output is correct |
48 | Correct | 82 ms | 20064 KB | Output is correct |
49 | Correct | 111 ms | 20260 KB | Output is correct |
50 | Correct | 246 ms | 20364 KB | Output is correct |
51 | Correct | 91 ms | 20292 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5071 ms | 46236 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5051 ms | 46552 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 14284 KB | Output is correct |
2 | Correct | 9 ms | 14376 KB | Output is correct |
3 | Correct | 8 ms | 14284 KB | Output is correct |
4 | Correct | 8 ms | 14284 KB | Output is correct |
5 | Correct | 9 ms | 14364 KB | Output is correct |
6 | Correct | 9 ms | 14412 KB | Output is correct |
7 | Correct | 12 ms | 14388 KB | Output is correct |
8 | Correct | 10 ms | 14412 KB | Output is correct |
9 | Correct | 12 ms | 14412 KB | Output is correct |
10 | Correct | 10 ms | 14388 KB | Output is correct |
11 | Correct | 9 ms | 14392 KB | Output is correct |
12 | Correct | 9 ms | 14388 KB | Output is correct |
13 | Correct | 8 ms | 14388 KB | Output is correct |
14 | Correct | 9 ms | 14340 KB | Output is correct |
15 | Correct | 9 ms | 14412 KB | Output is correct |
16 | Correct | 9 ms | 14348 KB | Output is correct |
17 | Correct | 9 ms | 14384 KB | Output is correct |
18 | Correct | 9 ms | 14388 KB | Output is correct |
19 | Correct | 10 ms | 14412 KB | Output is correct |
20 | Correct | 9 ms | 14412 KB | Output is correct |
21 | Correct | 9 ms | 14388 KB | Output is correct |
22 | Correct | 10 ms | 14440 KB | Output is correct |
23 | Correct | 9 ms | 14412 KB | Output is correct |
24 | Correct | 10 ms | 14392 KB | Output is correct |
25 | Correct | 11 ms | 14416 KB | Output is correct |
26 | Correct | 10 ms | 14412 KB | Output is correct |
27 | Correct | 10 ms | 14360 KB | Output is correct |
28 | Correct | 10 ms | 14304 KB | Output is correct |
29 | Correct | 10 ms | 14408 KB | Output is correct |
30 | Correct | 10 ms | 14412 KB | Output is correct |
31 | Correct | 2262 ms | 23336 KB | Output is correct |
32 | Correct | 118 ms | 19316 KB | Output is correct |
33 | Correct | 189 ms | 21348 KB | Output is correct |
34 | Correct | 1772 ms | 21572 KB | Output is correct |
35 | Correct | 1020 ms | 23256 KB | Output is correct |
36 | Correct | 242 ms | 23128 KB | Output is correct |
37 | Correct | 187 ms | 20700 KB | Output is correct |
38 | Correct | 122 ms | 20548 KB | Output is correct |
39 | Correct | 107 ms | 20300 KB | Output is correct |
40 | Correct | 97 ms | 20308 KB | Output is correct |
41 | Correct | 307 ms | 20656 KB | Output is correct |
42 | Correct | 385 ms | 20476 KB | Output is correct |
43 | Correct | 367 ms | 22792 KB | Output is correct |
44 | Correct | 249 ms | 20668 KB | Output is correct |
45 | Correct | 128 ms | 20596 KB | Output is correct |
46 | Correct | 83 ms | 20660 KB | Output is correct |
47 | Correct | 79 ms | 20148 KB | Output is correct |
48 | Correct | 82 ms | 20064 KB | Output is correct |
49 | Correct | 111 ms | 20260 KB | Output is correct |
50 | Correct | 246 ms | 20364 KB | Output is correct |
51 | Correct | 91 ms | 20292 KB | Output is correct |
52 | Execution timed out | 5050 ms | 21232 KB | Time limit exceeded |
53 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 14284 KB | Output is correct |
2 | Correct | 9 ms | 14376 KB | Output is correct |
3 | Correct | 8 ms | 14284 KB | Output is correct |
4 | Correct | 8 ms | 14284 KB | Output is correct |
5 | Correct | 9 ms | 14364 KB | Output is correct |
6 | Correct | 9 ms | 14412 KB | Output is correct |
7 | Correct | 12 ms | 14388 KB | Output is correct |
8 | Correct | 10 ms | 14412 KB | Output is correct |
9 | Correct | 12 ms | 14412 KB | Output is correct |
10 | Correct | 10 ms | 14388 KB | Output is correct |
11 | Correct | 9 ms | 14392 KB | Output is correct |
12 | Correct | 9 ms | 14388 KB | Output is correct |
13 | Correct | 8 ms | 14388 KB | Output is correct |
14 | Correct | 9 ms | 14340 KB | Output is correct |
15 | Correct | 9 ms | 14412 KB | Output is correct |
16 | Correct | 9 ms | 14348 KB | Output is correct |
17 | Correct | 9 ms | 14384 KB | Output is correct |
18 | Correct | 9 ms | 14388 KB | Output is correct |
19 | Correct | 10 ms | 14412 KB | Output is correct |
20 | Correct | 9 ms | 14412 KB | Output is correct |
21 | Correct | 9 ms | 14388 KB | Output is correct |
22 | Correct | 10 ms | 14440 KB | Output is correct |
23 | Correct | 9 ms | 14412 KB | Output is correct |
24 | Correct | 10 ms | 14392 KB | Output is correct |
25 | Correct | 11 ms | 14416 KB | Output is correct |
26 | Correct | 10 ms | 14412 KB | Output is correct |
27 | Correct | 10 ms | 14360 KB | Output is correct |
28 | Correct | 10 ms | 14304 KB | Output is correct |
29 | Correct | 10 ms | 14408 KB | Output is correct |
30 | Correct | 10 ms | 14412 KB | Output is correct |
31 | Correct | 2262 ms | 23336 KB | Output is correct |
32 | Correct | 118 ms | 19316 KB | Output is correct |
33 | Correct | 189 ms | 21348 KB | Output is correct |
34 | Correct | 1772 ms | 21572 KB | Output is correct |
35 | Correct | 1020 ms | 23256 KB | Output is correct |
36 | Correct | 242 ms | 23128 KB | Output is correct |
37 | Correct | 187 ms | 20700 KB | Output is correct |
38 | Correct | 122 ms | 20548 KB | Output is correct |
39 | Correct | 107 ms | 20300 KB | Output is correct |
40 | Correct | 97 ms | 20308 KB | Output is correct |
41 | Correct | 307 ms | 20656 KB | Output is correct |
42 | Correct | 385 ms | 20476 KB | Output is correct |
43 | Correct | 367 ms | 22792 KB | Output is correct |
44 | Correct | 249 ms | 20668 KB | Output is correct |
45 | Correct | 128 ms | 20596 KB | Output is correct |
46 | Correct | 83 ms | 20660 KB | Output is correct |
47 | Correct | 79 ms | 20148 KB | Output is correct |
48 | Correct | 82 ms | 20064 KB | Output is correct |
49 | Correct | 111 ms | 20260 KB | Output is correct |
50 | Correct | 246 ms | 20364 KB | Output is correct |
51 | Correct | 91 ms | 20292 KB | Output is correct |
52 | Execution timed out | 5071 ms | 46236 KB | Time limit exceeded |
53 | Halted | 0 ms | 0 KB | - |