# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
260787 | 2020-08-11T01:35:58 Z | T0p_ | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 702 ms | 6004 KB |
#include<bits/stdc++.h> using namespace std; struct DJK { int node; long long weight; bool operator < (const DJK & o) const { return weight > o.weight; } }; vector<int> B[30003]; long long dis[30003]; bool visit[30003]; priority_queue<DJK> djk; int main() { int n, m, s, e; scanf(" %d %d",&n,&m); for(int i=1, b, p ; i<=m ; i++) { scanf(" %d %d",&b,&p); b++; B[b].push_back(p); if(i == 1) s = b; if(i == 2) e = b; } for(int i=1 ; i<=n ; i++) dis[i] = 1e15; dis[s] = 0; djk.push({s, 0}); while(!djk.empty()) { int nown = djk.top().node; long long noww = djk.top().weight; djk.pop(); if(visit[nown]) continue ; visit[nown] = true; if(nown == e) { printf("%lld\n",noww); return 0; } for(auto x : B[nown]) { //left for(int i=1 ; nown - x*i >= 1 ; i++) if(dis[nown - x*i] > dis[nown] + i) { dis[nown - x*i] = dis[nown]+i; djk.push({nown - x*i, dis[nown - x*i]}); } //right for(int i=1 ; nown + x*i <= n ; i++) if(dis[nown + x*i] > dis[nown] + i) { dis[nown + x*i] = dis[nown]+i; djk.push({nown + x*i, dis[nown + x*i]}); } } } printf("-1\n"); 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 | 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 | 2 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 | 2 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 | 1152 KB | Output is correct |
10 | Correct | 1 ms | 1024 KB | Output is correct |
11 | Correct | 2 ms | 1024 KB | Output is correct |
12 | Correct | 2 ms | 1024 KB | Output is correct |
13 | Correct | 2 ms | 1024 KB | Output is correct |
14 | Correct | 1 ms | 1024 KB | Output is correct |
15 | Correct | 1 ms | 1024 KB | Output is correct |
16 | Correct | 2 ms | 1024 KB | Output is correct |
17 | Correct | 2 ms | 1088 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 | 2 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 | 4 ms | 1408 KB | Output is correct |
34 | Correct | 3 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 | 1 ms | 1024 KB | Output is correct |
10 | Correct | 1 ms | 1024 KB | Output is correct |
11 | Correct | 2 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 | 2 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 | 2 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 | 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 | 12 ms | 1536 KB | Output is correct |
36 | Correct | 3 ms | 1152 KB | Output is correct |
37 | Correct | 7 ms | 1536 KB | Output is correct |
38 | Correct | 11 ms | 1792 KB | Output is correct |
39 | Correct | 10 ms | 1768 KB | Output is correct |
40 | Correct | 10 ms | 1792 KB | Output is correct |
41 | Correct | 11 ms | 1792 KB | Output is correct |
42 | Correct | 10 ms | 1536 KB | Output is correct |
43 | Correct | 10 ms | 1544 KB | Output is correct |
44 | Correct | 53 ms | 1544 KB | Output is correct |
45 | Correct | 10 ms | 1920 KB | Output is correct |
46 | Correct | 10 ms | 1792 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 | 2 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 | 1080 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 | 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 | 9 ms | 1536 KB | Output is correct |
36 | Correct | 3 ms | 1152 KB | Output is correct |
37 | Correct | 7 ms | 1536 KB | Output is correct |
38 | Correct | 12 ms | 1792 KB | Output is correct |
39 | Correct | 11 ms | 1664 KB | Output is correct |
40 | Correct | 11 ms | 1792 KB | Output is correct |
41 | Correct | 11 ms | 1792 KB | Output is correct |
42 | Correct | 7 ms | 1536 KB | Output is correct |
43 | Correct | 7 ms | 1536 KB | Output is correct |
44 | Correct | 54 ms | 1536 KB | Output is correct |
45 | Correct | 13 ms | 1792 KB | Output is correct |
46 | Correct | 10 ms | 1792 KB | Output is correct |
47 | Correct | 12 ms | 2812 KB | Output is correct |
48 | Correct | 10 ms | 1920 KB | Output is correct |
49 | Correct | 9 ms | 1920 KB | Output is correct |
50 | Correct | 7 ms | 1792 KB | Output is correct |
51 | Correct | 27 ms | 4472 KB | Output is correct |
52 | Correct | 22 ms | 3452 KB | Output is correct |
53 | Correct | 14 ms | 2560 KB | Output is correct |
54 | Correct | 3 ms | 1664 KB | Output is correct |
55 | Correct | 3 ms | 1792 KB | Output is correct |
56 | Correct | 702 ms | 3316 KB | Output is correct |
57 | Correct | 5 ms | 3572 KB | Output is correct |
58 | Correct | 686 ms | 1920 KB | Output is correct |
59 | Correct | 11 ms | 2172 KB | Output is correct |
60 | Correct | 10 ms | 1920 KB | Output is correct |
61 | Correct | 10 ms | 2040 KB | Output is correct |
62 | Correct | 14 ms | 2560 KB | Output is correct |
63 | Correct | 31 ms | 3960 KB | Output is correct |
64 | Correct | 30 ms | 3960 KB | Output is correct |
65 | Correct | 38 ms | 6004 KB | Output is correct |
66 | Correct | 52 ms | 5872 KB | Output is correct |
67 | Correct | 41 ms | 5872 KB | Output is correct |