# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260799 | 2020-08-11T02:07:49 Z | my99n | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 943 ms | 5744 KB |
#include<bits/stdc++.h> using namespace std; struct A { long long n, w; bool operator < (const A & o) const { return w > o.w; } }; vector<int> P[30100]; int visited[30100]; long long dis[30100]; priority_queue<A> heap; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, s, e; cin >> n >> m; for (int i = 0; i < m; i++) { int b, p; cin >> b >> p; P[b].push_back(p); if (i == 0) s = b; if (i == 1) e = b; } for (int i = 0; i <= n; i++) dis[i] = 1e18; heap.push({s, 0}); while (!heap.empty()) { auto t = heap.top(); heap.pop(); if (visited[t.n]) continue; visited[t.n] = 1; dis[t.n] = t.w; if (t.n == e) { cout << t.w << endl; return 0; } for (auto p : P[t.n]) { for (int j = 1; t.n - j*p >= 0; j++) { if (t.w+j < dis[t.n-j*p]) { dis[t.n-j*p] = t.w+j; heap.push({t.n - j*p, t.w+j}); // cerr << "push " << t.n - j*p << ' ' << t.w+j; } } for (int j = 1; t.n + j*p < n; j++) { if (t.w+j < dis[t.n+j*p]) { dis[t.n+j*p] = t.w+j; heap.push({t.n + j*p, t.w+j}); // cerr << "push " << t.n + j*p << ' ' << t.w+j; } } } } cout << -1 << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1024 KB | Output is correct |
2 | Correct | 1 ms | 1024 KB | Output is correct |
3 | Correct | 1 ms | 1024 KB | Output is correct |
4 | Correct | 1 ms | 1024 KB | Output is correct |
5 | Correct | 1 ms | 1024 KB | Output is correct |
6 | Correct | 1 ms | 1024 KB | Output is correct |
7 | Correct | 1 ms | 1024 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1024 KB | Output is correct |
2 | Correct | 1 ms | 1024 KB | Output is correct |
3 | Correct | 1 ms | 1024 KB | Output is correct |
4 | Correct | 1 ms | 1024 KB | Output is correct |
5 | Correct | 1 ms | 1024 KB | Output is correct |
6 | Correct | 2 ms | 1024 KB | Output is correct |
7 | Correct | 1 ms | 1024 KB | Output is correct |
8 | Correct | 1 ms | 1024 KB | Output is correct |
9 | Correct | 1 ms | 1024 KB | Output is correct |
10 | Correct | 1 ms | 1024 KB | Output is correct |
11 | Correct | 1 ms | 1024 KB | Output is correct |
12 | Correct | 1 ms | 1024 KB | Output is correct |
13 | Correct | 1 ms | 1024 KB | Output is correct |
14 | Correct | 1 ms | 1024 KB | Output is correct |
15 | Correct | 1 ms | 1024 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1024 KB | Output is correct |
2 | Correct | 1 ms | 1024 KB | Output is correct |
3 | Correct | 1 ms | 1024 KB | Output is correct |
4 | Correct | 1 ms | 1024 KB | Output is correct |
5 | Correct | 1 ms | 1024 KB | Output is correct |
6 | Correct | 1 ms | 1024 KB | Output is correct |
7 | Correct | 1 ms | 1024 KB | Output is correct |
8 | Correct | 1 ms | 1024 KB | Output is correct |
9 | Correct | 1 ms | 1024 KB | Output is correct |
10 | Correct | 1 ms | 1024 KB | Output is correct |
11 | Correct | 1 ms | 1024 KB | Output is correct |
12 | Correct | 1 ms | 1024 KB | Output is correct |
13 | Correct | 1 ms | 1024 KB | Output is correct |
14 | Correct | 1 ms | 1024 KB | Output is correct |
15 | Correct | 2 ms | 1024 KB | Output is correct |
16 | Correct | 1 ms | 1024 KB | Output is correct |
17 | Correct | 2 ms | 1152 KB | Output is correct |
18 | Correct | 1 ms | 1024 KB | Output is correct |
19 | Correct | 1 ms | 1024 KB | Output is correct |
20 | Correct | 5 ms | 1152 KB | Output is correct |
21 | Correct | 1 ms | 1024 KB | Output is correct |
22 | Correct | 1 ms | 1024 KB | Output is correct |
23 | Correct | 2 ms | 1152 KB | Output is correct |
24 | Correct | 2 ms | 1152 KB | Output is correct |
25 | Correct | 2 ms | 1152 KB | Output is correct |
26 | Correct | 1 ms | 1152 KB | Output is correct |
27 | Correct | 2 ms | 1152 KB | Output is correct |
28 | Correct | 2 ms | 1152 KB | Output is correct |
29 | Correct | 2 ms | 1408 KB | Output is correct |
30 | Correct | 2 ms | 1280 KB | Output is correct |
31 | Correct | 2 ms | 1280 KB | Output is correct |
32 | Correct | 2 ms | 1280 KB | Output is correct |
33 | Correct | 3 ms | 1408 KB | Output is correct |
34 | Correct | 2 ms | 1408 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1024 KB | Output is correct |
2 | Correct | 1 ms | 1024 KB | Output is correct |
3 | Correct | 1 ms | 1024 KB | Output is correct |
4 | Correct | 1 ms | 1024 KB | Output is correct |
5 | Correct | 1 ms | 1024 KB | Output is correct |
6 | Correct | 1 ms | 1024 KB | Output is correct |
7 | Correct | 1 ms | 1024 KB | Output is correct |
8 | Correct | 1 ms | 1024 KB | Output is correct |
9 | Correct | 2 ms | 1024 KB | Output is correct |
10 | Correct | 1 ms | 1024 KB | Output is correct |
11 | Correct | 1 ms | 1024 KB | Output is correct |
12 | Correct | 1 ms | 1024 KB | Output is correct |
13 | Correct | 2 ms | 1024 KB | Output is correct |
14 | Correct | 2 ms | 1024 KB | Output is correct |
15 | Correct | 1 ms | 1024 KB | Output is correct |
16 | Correct | 1 ms | 1024 KB | Output is correct |
17 | Correct | 2 ms | 1152 KB | Output is correct |
18 | Correct | 1 ms | 1024 KB | Output is correct |
19 | Correct | 1 ms | 1024 KB | Output is correct |
20 | Correct | 5 ms | 1152 KB | Output is correct |
21 | Correct | 1 ms | 1024 KB | Output is correct |
22 | Correct | 1 ms | 1024 KB | Output is correct |
23 | Correct | 2 ms | 1152 KB | Output is correct |
24 | Correct | 2 ms | 1152 KB | Output is correct |
25 | Correct | 2 ms | 1152 KB | Output is correct |
26 | Correct | 2 ms | 1152 KB | Output is correct |
27 | Correct | 1 ms | 1152 KB | Output is correct |
28 | Correct | 2 ms | 1152 KB | Output is correct |
29 | Correct | 3 ms | 1408 KB | Output is correct |
30 | Correct | 2 ms | 1280 KB | Output is correct |
31 | Correct | 2 ms | 1280 KB | Output is correct |
32 | Correct | 2 ms | 1280 KB | Output is correct |
33 | Correct | 3 ms | 1408 KB | Output is correct |
34 | Correct | 3 ms | 1408 KB | Output is correct |
35 | Correct | 8 ms | 1408 KB | Output is correct |
36 | Correct | 2 ms | 1152 KB | Output is correct |
37 | Correct | 6 ms | 1536 KB | Output is correct |
38 | Correct | 9 ms | 1536 KB | Output is correct |
39 | Correct | 8 ms | 1408 KB | Output is correct |
40 | Correct | 9 ms | 1536 KB | Output is correct |
41 | Correct | 11 ms | 1536 KB | Output is correct |
42 | Correct | 6 ms | 1280 KB | Output is correct |
43 | Correct | 6 ms | 1280 KB | Output is correct |
44 | Correct | 50 ms | 1280 KB | Output is correct |
45 | Correct | 9 ms | 1664 KB | Output is correct |
46 | Correct | 8 ms | 1664 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1024 KB | Output is correct |
2 | Correct | 1 ms | 1024 KB | Output is correct |
3 | Correct | 1 ms | 1024 KB | Output is correct |
4 | Correct | 1 ms | 1024 KB | Output is correct |
5 | Correct | 1 ms | 1024 KB | Output is correct |
6 | Correct | 1 ms | 1024 KB | Output is correct |
7 | Correct | 1 ms | 1024 KB | Output is correct |
8 | Correct | 1 ms | 1024 KB | Output is correct |
9 | Correct | 1 ms | 1024 KB | Output is correct |
10 | Correct | 1 ms | 1024 KB | Output is correct |
11 | Correct | 1 ms | 1024 KB | Output is correct |
12 | Correct | 1 ms | 1024 KB | Output is correct |
13 | Correct | 1 ms | 1024 KB | Output is correct |
14 | Correct | 1 ms | 1024 KB | Output is correct |
15 | Correct | 2 ms | 1152 KB | Output is correct |
16 | Correct | 1 ms | 1024 KB | Output is correct |
17 | Correct | 2 ms | 1152 KB | Output is correct |
18 | Correct | 1 ms | 1024 KB | Output is correct |
19 | Correct | 1 ms | 1024 KB | Output is correct |
20 | Correct | 7 ms | 1312 KB | Output is correct |
21 | Correct | 1 ms | 1024 KB | Output is correct |
22 | Correct | 2 ms | 1024 KB | Output is correct |
23 | Correct | 1 ms | 1152 KB | Output is correct |
24 | Correct | 2 ms | 1152 KB | Output is correct |
25 | Correct | 2 ms | 1152 KB | Output is correct |
26 | Correct | 1 ms | 1152 KB | Output is correct |
27 | Correct | 1 ms | 1152 KB | Output is correct |
28 | Correct | 2 ms | 1152 KB | Output is correct |
29 | Correct | 2 ms | 1408 KB | Output is correct |
30 | Correct | 2 ms | 1280 KB | Output is correct |
31 | Correct | 2 ms | 1280 KB | Output is correct |
32 | Correct | 2 ms | 1280 KB | Output is correct |
33 | Correct | 3 ms | 1408 KB | Output is correct |
34 | Correct | 3 ms | 1536 KB | Output is correct |
35 | Correct | 8 ms | 1408 KB | Output is correct |
36 | Correct | 2 ms | 1152 KB | Output is correct |
37 | Correct | 6 ms | 1536 KB | Output is correct |
38 | Correct | 9 ms | 1568 KB | Output is correct |
39 | Correct | 8 ms | 1408 KB | Output is correct |
40 | Correct | 9 ms | 1536 KB | Output is correct |
41 | Correct | 10 ms | 1536 KB | Output is correct |
42 | Correct | 7 ms | 1280 KB | Output is correct |
43 | Correct | 6 ms | 1280 KB | Output is correct |
44 | Correct | 41 ms | 1280 KB | Output is correct |
45 | Correct | 9 ms | 1664 KB | Output is correct |
46 | Correct | 8 ms | 1664 KB | Output is correct |
47 | Correct | 11 ms | 2680 KB | Output is correct |
48 | Correct | 8 ms | 1664 KB | Output is correct |
49 | Correct | 8 ms | 1664 KB | Output is correct |
50 | Correct | 6 ms | 1664 KB | Output is correct |
51 | Correct | 18 ms | 4212 KB | Output is correct |
52 | Correct | 19 ms | 3192 KB | Output is correct |
53 | Correct | 12 ms | 2304 KB | Output is correct |
54 | Correct | 3 ms | 1792 KB | Output is correct |
55 | Correct | 3 ms | 1792 KB | Output is correct |
56 | Correct | 726 ms | 3188 KB | Output is correct |
57 | Correct | 5 ms | 3568 KB | Output is correct |
58 | Correct | 943 ms | 1916 KB | Output is correct |
59 | Correct | 10 ms | 1916 KB | Output is correct |
60 | Correct | 9 ms | 1948 KB | Output is correct |
61 | Correct | 10 ms | 1916 KB | Output is correct |
62 | Correct | 13 ms | 2304 KB | Output is correct |
63 | Correct | 30 ms | 3700 KB | Output is correct |
64 | Correct | 30 ms | 3700 KB | Output is correct |
65 | Correct | 38 ms | 5744 KB | Output is correct |
66 | Correct | 54 ms | 5744 KB | Output is correct |
67 | Correct | 42 ms | 5744 KB | Output is correct |