# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1113075 | 2024-11-15T16:20:58 Z | adaawf | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1000 ms | 2128 KB |
#include <iostream> #include <vector> using namespace std; vector<int> g[30005]; int f[30005], da[30005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, h, k; cin >> n >> m; for (int i = 1; i <= m; i++) { int x, y; cin >> x >> y; if (i == 1) h = x; if (i == 2) k = x; g[x].push_back(y); } for (int i = 0; i < n; i++) f[i] = 1e9; f[h] = 0; for (int jj = 0; jj < n; jj++) { int p, mi = 1e9; for (int i = 0; i < n; i++) { if (da[i] == 0 && mi > f[i]) { mi = f[i]; p = i; } } da[p] = 1; for (int w : g[p]) { int l = 0; for (int j = p - w; j >= 0; j -= w) { f[j] = min(f[j], f[p] + l + 1); l++; } l = 0; for (int j = p + w; j < n; j += w) { f[j] = min(f[j], f[p] + l + 1); l++; } } } if (f[k] == 1e9) cout << -1; else cout << f[k]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1104 KB | Output is correct |
2 | Correct | 1 ms | 1104 KB | Output is correct |
3 | Correct | 1 ms | 1104 KB | Output is correct |
4 | Correct | 1 ms | 1104 KB | Output is correct |
5 | Correct | 1 ms | 1104 KB | Output is correct |
6 | Correct | 1 ms | 1104 KB | Output is correct |
7 | Correct | 1 ms | 1272 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1104 KB | Output is correct |
2 | Correct | 1 ms | 1104 KB | Output is correct |
3 | Correct | 1 ms | 1104 KB | Output is correct |
4 | Correct | 1 ms | 1104 KB | Output is correct |
5 | Correct | 1 ms | 1272 KB | Output is correct |
6 | Correct | 1 ms | 1104 KB | Output is correct |
7 | Correct | 1 ms | 1104 KB | Output is correct |
8 | Correct | 1 ms | 1104 KB | Output is correct |
9 | Correct | 1 ms | 1104 KB | Output is correct |
10 | Correct | 2 ms | 1156 KB | Output is correct |
11 | Correct | 2 ms | 1104 KB | Output is correct |
12 | Correct | 2 ms | 1104 KB | Output is correct |
13 | Correct | 2 ms | 1104 KB | Output is correct |
14 | Correct | 1 ms | 1104 KB | Output is correct |
15 | Correct | 1 ms | 1104 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1104 KB | Output is correct |
2 | Correct | 1 ms | 1176 KB | Output is correct |
3 | Correct | 2 ms | 1272 KB | Output is correct |
4 | Correct | 1 ms | 1104 KB | Output is correct |
5 | Correct | 2 ms | 1104 KB | Output is correct |
6 | Correct | 1 ms | 1104 KB | Output is correct |
7 | Correct | 1 ms | 1104 KB | Output is correct |
8 | Correct | 1 ms | 1104 KB | Output is correct |
9 | Correct | 1 ms | 1104 KB | Output is correct |
10 | Correct | 2 ms | 1104 KB | Output is correct |
11 | Correct | 2 ms | 1104 KB | Output is correct |
12 | Correct | 2 ms | 1104 KB | Output is correct |
13 | Correct | 2 ms | 1104 KB | Output is correct |
14 | Correct | 2 ms | 1288 KB | Output is correct |
15 | Correct | 1 ms | 1104 KB | Output is correct |
16 | Correct | 2 ms | 1104 KB | Output is correct |
17 | Correct | 2 ms | 1104 KB | Output is correct |
18 | Correct | 4 ms | 1224 KB | Output is correct |
19 | Correct | 8 ms | 1104 KB | Output is correct |
20 | Correct | 7 ms | 1104 KB | Output is correct |
21 | Correct | 2 ms | 1104 KB | Output is correct |
22 | Correct | 6 ms | 1360 KB | Output is correct |
23 | Correct | 4 ms | 1104 KB | Output is correct |
24 | Correct | 5 ms | 1252 KB | Output is correct |
25 | Correct | 6 ms | 1104 KB | Output is correct |
26 | Correct | 7 ms | 1104 KB | Output is correct |
27 | Correct | 7 ms | 1104 KB | Output is correct |
28 | Correct | 6 ms | 1104 KB | Output is correct |
29 | Correct | 5 ms | 1104 KB | Output is correct |
30 | Correct | 4 ms | 1104 KB | Output is correct |
31 | Correct | 5 ms | 1104 KB | Output is correct |
32 | Correct | 4 ms | 1104 KB | Output is correct |
33 | Correct | 5 ms | 1104 KB | Output is correct |
34 | Correct | 5 ms | 1104 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1104 KB | Output is correct |
2 | Correct | 1 ms | 1104 KB | Output is correct |
3 | Correct | 2 ms | 1104 KB | Output is correct |
4 | Correct | 1 ms | 1104 KB | Output is correct |
5 | Correct | 1 ms | 1104 KB | Output is correct |
6 | Correct | 1 ms | 1104 KB | Output is correct |
7 | Correct | 1 ms | 1104 KB | Output is correct |
8 | Correct | 2 ms | 1104 KB | Output is correct |
9 | Correct | 1 ms | 1104 KB | Output is correct |
10 | Correct | 2 ms | 1104 KB | Output is correct |
11 | Correct | 1 ms | 1372 KB | Output is correct |
12 | Correct | 1 ms | 1104 KB | Output is correct |
13 | Correct | 2 ms | 1104 KB | Output is correct |
14 | Correct | 1 ms | 1104 KB | Output is correct |
15 | Correct | 2 ms | 1360 KB | Output is correct |
16 | Correct | 1 ms | 1104 KB | Output is correct |
17 | Correct | 2 ms | 1104 KB | Output is correct |
18 | Correct | 4 ms | 1180 KB | Output is correct |
19 | Correct | 4 ms | 1104 KB | Output is correct |
20 | Correct | 8 ms | 1104 KB | Output is correct |
21 | Correct | 2 ms | 1104 KB | Output is correct |
22 | Correct | 4 ms | 1104 KB | Output is correct |
23 | Correct | 4 ms | 1104 KB | Output is correct |
24 | Correct | 5 ms | 1104 KB | Output is correct |
25 | Correct | 6 ms | 1256 KB | Output is correct |
26 | Correct | 7 ms | 1104 KB | Output is correct |
27 | Correct | 7 ms | 1104 KB | Output is correct |
28 | Correct | 6 ms | 1160 KB | Output is correct |
29 | Correct | 4 ms | 1104 KB | Output is correct |
30 | Correct | 4 ms | 1272 KB | Output is correct |
31 | Correct | 4 ms | 1104 KB | Output is correct |
32 | Correct | 4 ms | 1104 KB | Output is correct |
33 | Correct | 5 ms | 1104 KB | Output is correct |
34 | Correct | 5 ms | 1104 KB | Output is correct |
35 | Correct | 7 ms | 1504 KB | Output is correct |
36 | Correct | 3 ms | 1104 KB | Output is correct |
37 | Correct | 8 ms | 1360 KB | Output is correct |
38 | Correct | 13 ms | 1784 KB | Output is correct |
39 | Correct | 10 ms | 1616 KB | Output is correct |
40 | Correct | 9 ms | 1616 KB | Output is correct |
41 | Correct | 9 ms | 1616 KB | Output is correct |
42 | Correct | 47 ms | 1616 KB | Output is correct |
43 | Correct | 50 ms | 1616 KB | Output is correct |
44 | Correct | 47 ms | 1644 KB | Output is correct |
45 | Correct | 9 ms | 1720 KB | Output is correct |
46 | Correct | 8 ms | 1616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1104 KB | Output is correct |
2 | Correct | 1 ms | 1104 KB | Output is correct |
3 | Correct | 1 ms | 1280 KB | Output is correct |
4 | Correct | 1 ms | 1172 KB | Output is correct |
5 | Correct | 1 ms | 1104 KB | Output is correct |
6 | Correct | 1 ms | 1104 KB | Output is correct |
7 | Correct | 1 ms | 1104 KB | Output is correct |
8 | Correct | 1 ms | 1104 KB | Output is correct |
9 | Correct | 1 ms | 1276 KB | Output is correct |
10 | Correct | 1 ms | 1104 KB | Output is correct |
11 | Correct | 2 ms | 1104 KB | Output is correct |
12 | Correct | 1 ms | 1272 KB | Output is correct |
13 | Correct | 1 ms | 1104 KB | Output is correct |
14 | Correct | 1 ms | 1104 KB | Output is correct |
15 | Correct | 2 ms | 1104 KB | Output is correct |
16 | Correct | 1 ms | 1104 KB | Output is correct |
17 | Correct | 2 ms | 1104 KB | Output is correct |
18 | Correct | 3 ms | 1104 KB | Output is correct |
19 | Correct | 4 ms | 1104 KB | Output is correct |
20 | Correct | 7 ms | 1104 KB | Output is correct |
21 | Correct | 1 ms | 1104 KB | Output is correct |
22 | Correct | 3 ms | 1104 KB | Output is correct |
23 | Correct | 4 ms | 1104 KB | Output is correct |
24 | Correct | 6 ms | 1104 KB | Output is correct |
25 | Correct | 5 ms | 1256 KB | Output is correct |
26 | Correct | 7 ms | 1104 KB | Output is correct |
27 | Correct | 7 ms | 1224 KB | Output is correct |
28 | Correct | 5 ms | 1276 KB | Output is correct |
29 | Correct | 4 ms | 1376 KB | Output is correct |
30 | Correct | 4 ms | 1104 KB | Output is correct |
31 | Correct | 7 ms | 1104 KB | Output is correct |
32 | Correct | 4 ms | 1104 KB | Output is correct |
33 | Correct | 4 ms | 1212 KB | Output is correct |
34 | Correct | 5 ms | 1104 KB | Output is correct |
35 | Correct | 7 ms | 1616 KB | Output is correct |
36 | Correct | 4 ms | 1104 KB | Output is correct |
37 | Correct | 11 ms | 1372 KB | Output is correct |
38 | Correct | 10 ms | 1616 KB | Output is correct |
39 | Correct | 9 ms | 1628 KB | Output is correct |
40 | Correct | 9 ms | 1852 KB | Output is correct |
41 | Correct | 9 ms | 1872 KB | Output is correct |
42 | Correct | 60 ms | 1360 KB | Output is correct |
43 | Correct | 47 ms | 1616 KB | Output is correct |
44 | Correct | 47 ms | 1616 KB | Output is correct |
45 | Correct | 8 ms | 1616 KB | Output is correct |
46 | Correct | 7 ms | 1616 KB | Output is correct |
47 | Correct | 177 ms | 1616 KB | Output is correct |
48 | Correct | 383 ms | 1956 KB | Output is correct |
49 | Correct | 458 ms | 1872 KB | Output is correct |
50 | Correct | 540 ms | 1616 KB | Output is correct |
51 | Execution timed out | 1062 ms | 2128 KB | Time limit exceeded |
52 | Halted | 0 ms | 0 KB | - |