# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
870612 | 2023-11-08T13:32:02 Z | anha3k25cvp | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 131 ms | 65708 KB |
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define dl double #define st first #define nd second #define II pair <int, int> using namespace std; const int N = 5 + 1e5; const int inf = 7 + 1e9; int n, m; vector <int> b, p; namespace subtask5 { void main() { vector <set <int>> g(n); for (int i = 1; i <= m; i ++) g[b[i]].insert(p[i]); vector <vector <II>> adj(n); for (int i = 0; i < n; i ++) for (int val : g[i]) { for (int j = 1; j * val <= i; j ++) { adj[i].push_back({i - j * val, j}); if (g[i - j * val].count(val)) break; } for (int j = 1; i + j * val < n; j ++) { adj[i].push_back({i + j * val, j}); if (g[i + j * val].count(val)) break; } } vector <int> f(n, inf); priority_queue <II> q; q.push({-(f[b[1]] = 0), b[1]}); while (!q.empty()) { int du = -q.top().st, u = q.top().nd; q.pop(); if (f[u] < du) continue; if (u == b[2]) { cout << du; return; } for (auto z : adj[u]) { int v = z.st, w = z.nd; if (du + w < f[v]) q.push({-(f[v] = du + w), v}); } } cout << -1; } } int main() { #define TASKNAME "" ios_base :: sync_with_stdio (0); cin.tie (0); if ( fopen( TASKNAME".inp", "r" ) ) { freopen (TASKNAME".inp", "r", stdin); freopen (TASKNAME".out", "w", stdout); } cin >> n >> m; b.assign(m + 1, 0); p.assign(m + 1, 0); for (int i = 1; i <= m; i ++) cin >> b[i] >> p[i]; subtask5 :: main(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 452 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 392 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 556 KB | Output is correct |
15 | Correct | 1 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 600 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 464 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 604 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 604 KB | Output is correct |
18 | Correct | 1 ms | 604 KB | Output is correct |
19 | Correct | 1 ms | 604 KB | Output is correct |
20 | Correct | 1 ms | 740 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 604 KB | Output is correct |
23 | Correct | 1 ms | 600 KB | Output is correct |
24 | Correct | 2 ms | 860 KB | Output is correct |
25 | Correct | 1 ms | 604 KB | Output is correct |
26 | Correct | 1 ms | 852 KB | Output is correct |
27 | Correct | 1 ms | 600 KB | Output is correct |
28 | Correct | 1 ms | 860 KB | Output is correct |
29 | Correct | 2 ms | 1116 KB | Output is correct |
30 | Correct | 1 ms | 860 KB | Output is correct |
31 | Correct | 1 ms | 860 KB | Output is correct |
32 | Correct | 2 ms | 856 KB | Output is correct |
33 | Correct | 4 ms | 1880 KB | Output is correct |
34 | Correct | 3 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 452 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 456 KB | Output is correct |
11 | Correct | 1 ms | 604 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 856 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 604 KB | Output is correct |
18 | Correct | 1 ms | 604 KB | Output is correct |
19 | Correct | 1 ms | 604 KB | Output is correct |
20 | Correct | 1 ms | 604 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 604 KB | Output is correct |
23 | Correct | 1 ms | 604 KB | Output is correct |
24 | Correct | 2 ms | 856 KB | Output is correct |
25 | Correct | 1 ms | 604 KB | Output is correct |
26 | Correct | 1 ms | 604 KB | Output is correct |
27 | Correct | 1 ms | 604 KB | Output is correct |
28 | Correct | 1 ms | 860 KB | Output is correct |
29 | Correct | 3 ms | 1116 KB | Output is correct |
30 | Correct | 1 ms | 860 KB | Output is correct |
31 | Correct | 2 ms | 856 KB | Output is correct |
32 | Correct | 1 ms | 860 KB | Output is correct |
33 | Correct | 3 ms | 1996 KB | Output is correct |
34 | Correct | 3 ms | 1884 KB | Output is correct |
35 | Correct | 11 ms | 3184 KB | Output is correct |
36 | Correct | 2 ms | 856 KB | Output is correct |
37 | Correct | 12 ms | 3880 KB | Output is correct |
38 | Correct | 18 ms | 4184 KB | Output is correct |
39 | Correct | 15 ms | 4024 KB | Output is correct |
40 | Correct | 15 ms | 4184 KB | Output is correct |
41 | Correct | 17 ms | 4020 KB | Output is correct |
42 | Correct | 4 ms | 1112 KB | Output is correct |
43 | Correct | 4 ms | 900 KB | Output is correct |
44 | Correct | 3 ms | 1116 KB | Output is correct |
45 | Correct | 16 ms | 6760 KB | Output is correct |
46 | Correct | 15 ms | 6528 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 604 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 604 KB | Output is correct |
15 | Correct | 1 ms | 600 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 788 KB | Output is correct |
18 | Correct | 1 ms | 716 KB | Output is correct |
19 | Correct | 1 ms | 604 KB | Output is correct |
20 | Correct | 1 ms | 604 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 440 KB | Output is correct |
23 | Correct | 1 ms | 604 KB | Output is correct |
24 | Correct | 1 ms | 860 KB | Output is correct |
25 | Correct | 1 ms | 604 KB | Output is correct |
26 | Correct | 1 ms | 604 KB | Output is correct |
27 | Correct | 1 ms | 604 KB | Output is correct |
28 | Correct | 1 ms | 860 KB | Output is correct |
29 | Correct | 2 ms | 1116 KB | Output is correct |
30 | Correct | 2 ms | 860 KB | Output is correct |
31 | Correct | 1 ms | 860 KB | Output is correct |
32 | Correct | 1 ms | 856 KB | Output is correct |
33 | Correct | 3 ms | 1884 KB | Output is correct |
34 | Correct | 3 ms | 1884 KB | Output is correct |
35 | Correct | 11 ms | 3164 KB | Output is correct |
36 | Correct | 2 ms | 860 KB | Output is correct |
37 | Correct | 14 ms | 3676 KB | Output is correct |
38 | Correct | 15 ms | 4188 KB | Output is correct |
39 | Correct | 15 ms | 4204 KB | Output is correct |
40 | Correct | 15 ms | 4184 KB | Output is correct |
41 | Correct | 15 ms | 4188 KB | Output is correct |
42 | Correct | 3 ms | 1064 KB | Output is correct |
43 | Correct | 4 ms | 1116 KB | Output is correct |
44 | Correct | 4 ms | 1116 KB | Output is correct |
45 | Correct | 16 ms | 6748 KB | Output is correct |
46 | Correct | 15 ms | 6748 KB | Output is correct |
47 | Correct | 27 ms | 11804 KB | Output is correct |
48 | Correct | 12 ms | 5804 KB | Output is correct |
49 | Correct | 10 ms | 5212 KB | Output is correct |
50 | Correct | 8 ms | 4784 KB | Output is correct |
51 | Correct | 20 ms | 8580 KB | Output is correct |
52 | Correct | 22 ms | 8988 KB | Output is correct |
53 | Correct | 10 ms | 5544 KB | Output is correct |
54 | Correct | 3 ms | 3160 KB | Output is correct |
55 | Correct | 4 ms | 3544 KB | Output is correct |
56 | Correct | 10 ms | 5268 KB | Output is correct |
57 | Correct | 12 ms | 11356 KB | Output is correct |
58 | Correct | 7 ms | 4080 KB | Output is correct |
59 | Correct | 8 ms | 4312 KB | Output is correct |
60 | Correct | 8 ms | 4944 KB | Output is correct |
61 | Correct | 8 ms | 4316 KB | Output is correct |
62 | Correct | 16 ms | 9628 KB | Output is correct |
63 | Correct | 51 ms | 25804 KB | Output is correct |
64 | Correct | 56 ms | 29144 KB | Output is correct |
65 | Correct | 73 ms | 38860 KB | Output is correct |
66 | Correct | 131 ms | 65708 KB | Output is correct |
67 | Correct | 111 ms | 65676 KB | Output is correct |