# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
100121 | 2019-03-09T10:22:06 Z | TadijaSebez | Jakarta Skyscrapers (APIO15_skyscraper) | C++11 | 894 ms | 6256 KB |
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define ll long long const int N=30050; const ll inf=1e18; ll dist[N]; vector<int> jump[N]; int my[N],p[N]; int main() { int n,m,i; scanf("%i %i",&n,&m); for(i=1;i<=m;i++) scanf("%i %i",&my[i],&p[i]),my[i]++,jump[my[i]].push_back(p[i]); for(i=1;i<=n;i++) dist[i]=inf; priority_queue<pair<ll,int>> pq; pq.push(mp(0,my[1])); dist[my[1]]=0; while(pq.size()) { ll d=-pq.top().first; int z=pq.top().second; pq.pop(); if(d!=dist[z]) continue; for(int j:jump[z]) { int cnt=1; for(int i=z+j;i<=n;i+=j) { if(dist[i]>dist[z]+cnt) { dist[i]=dist[z]+cnt; pq.push(mp(-dist[i],i)); } cnt++; } cnt=1; for(int i=z-j;i>=1;i-=j) { if(dist[i]>dist[z]+cnt) { dist[i]=dist[z]+cnt; pq.push(mp(-dist[i],i)); } cnt++; } } } if(dist[my[2]]==inf) printf("-1\n"); else printf("%lld\n",dist[my[2]]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1024 KB | Output is correct |
2 | Correct | 4 ms | 1024 KB | Output is correct |
3 | Correct | 2 ms | 1024 KB | Output is correct |
4 | Correct | 3 ms | 1024 KB | Output is correct |
5 | Correct | 2 ms | 1024 KB | Output is correct |
6 | Correct | 3 ms | 1024 KB | Output is correct |
7 | Correct | 3 ms | 1024 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1024 KB | Output is correct |
2 | Correct | 3 ms | 1024 KB | Output is correct |
3 | Correct | 2 ms | 1024 KB | Output is correct |
4 | Correct | 4 ms | 1024 KB | Output is correct |
5 | Correct | 4 ms | 1024 KB | Output is correct |
6 | Correct | 4 ms | 1024 KB | Output is correct |
7 | Correct | 2 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 1024 KB | Output is correct |
9 | Correct | 3 ms | 1024 KB | Output is correct |
10 | Correct | 2 ms | 1024 KB | Output is correct |
11 | Correct | 3 ms | 1024 KB | Output is correct |
12 | Correct | 3 ms | 1024 KB | Output is correct |
13 | Correct | 3 ms | 1024 KB | Output is correct |
14 | Correct | 3 ms | 1024 KB | Output is correct |
15 | Correct | 3 ms | 1024 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1024 KB | Output is correct |
2 | Correct | 3 ms | 1024 KB | Output is correct |
3 | Correct | 3 ms | 1024 KB | Output is correct |
4 | Correct | 2 ms | 1024 KB | Output is correct |
5 | Correct | 3 ms | 1024 KB | Output is correct |
6 | Correct | 3 ms | 1024 KB | Output is correct |
7 | Correct | 3 ms | 1024 KB | Output is correct |
8 | Correct | 4 ms | 1024 KB | Output is correct |
9 | Correct | 3 ms | 1024 KB | Output is correct |
10 | Correct | 2 ms | 1024 KB | Output is correct |
11 | Correct | 3 ms | 1024 KB | Output is correct |
12 | Correct | 3 ms | 1024 KB | Output is correct |
13 | Correct | 3 ms | 1024 KB | Output is correct |
14 | Correct | 4 ms | 1152 KB | Output is correct |
15 | Correct | 4 ms | 1024 KB | Output is correct |
16 | Correct | 4 ms | 1024 KB | Output is correct |
17 | Correct | 3 ms | 1152 KB | Output is correct |
18 | Correct | 3 ms | 1024 KB | Output is correct |
19 | Correct | 3 ms | 1024 KB | Output is correct |
20 | Correct | 6 ms | 1152 KB | Output is correct |
21 | Correct | 2 ms | 1024 KB | Output is correct |
22 | Correct | 3 ms | 1024 KB | Output is correct |
23 | Correct | 3 ms | 1152 KB | Output is correct |
24 | Correct | 3 ms | 1152 KB | Output is correct |
25 | Correct | 4 ms | 1252 KB | Output is correct |
26 | Correct | 6 ms | 1152 KB | Output is correct |
27 | Correct | 6 ms | 1152 KB | Output is correct |
28 | Correct | 3 ms | 1152 KB | Output is correct |
29 | Correct | 4 ms | 1280 KB | Output is correct |
30 | Correct | 3 ms | 1280 KB | Output is correct |
31 | Correct | 4 ms | 1280 KB | Output is correct |
32 | Correct | 3 ms | 1280 KB | Output is correct |
33 | Correct | 6 ms | 1408 KB | Output is correct |
34 | Correct | 4 ms | 1536 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1024 KB | Output is correct |
2 | Correct | 2 ms | 1024 KB | Output is correct |
3 | Correct | 2 ms | 1024 KB | Output is correct |
4 | Correct | 3 ms | 1024 KB | Output is correct |
5 | Correct | 2 ms | 1024 KB | Output is correct |
6 | Correct | 2 ms | 1024 KB | Output is correct |
7 | Correct | 3 ms | 1152 KB | Output is correct |
8 | Correct | 3 ms | 1024 KB | Output is correct |
9 | Correct | 2 ms | 1024 KB | Output is correct |
10 | Correct | 3 ms | 1024 KB | Output is correct |
11 | Correct | 3 ms | 1152 KB | Output is correct |
12 | Correct | 3 ms | 1152 KB | Output is correct |
13 | Correct | 3 ms | 1152 KB | Output is correct |
14 | Correct | 3 ms | 1068 KB | Output is correct |
15 | Correct | 3 ms | 1152 KB | Output is correct |
16 | Correct | 3 ms | 1024 KB | Output is correct |
17 | Correct | 3 ms | 1152 KB | Output is correct |
18 | Correct | 3 ms | 1152 KB | Output is correct |
19 | Correct | 3 ms | 1024 KB | Output is correct |
20 | Correct | 7 ms | 1152 KB | Output is correct |
21 | Correct | 3 ms | 1024 KB | Output is correct |
22 | Correct | 2 ms | 1024 KB | Output is correct |
23 | Correct | 3 ms | 1152 KB | Output is correct |
24 | Correct | 4 ms | 1152 KB | Output is correct |
25 | Correct | 4 ms | 1280 KB | Output is correct |
26 | Correct | 8 ms | 1152 KB | Output is correct |
27 | Correct | 5 ms | 1152 KB | Output is correct |
28 | Correct | 3 ms | 1152 KB | Output is correct |
29 | Correct | 4 ms | 1280 KB | Output is correct |
30 | Correct | 4 ms | 1252 KB | Output is correct |
31 | Correct | 3 ms | 1280 KB | Output is correct |
32 | Correct | 3 ms | 1280 KB | Output is correct |
33 | Correct | 4 ms | 1408 KB | Output is correct |
34 | Correct | 4 ms | 1536 KB | Output is correct |
35 | Correct | 9 ms | 1792 KB | Output is correct |
36 | Correct | 6 ms | 1280 KB | Output is correct |
37 | Correct | 9 ms | 1792 KB | Output is correct |
38 | Correct | 11 ms | 2048 KB | Output is correct |
39 | Correct | 11 ms | 1920 KB | Output is correct |
40 | Correct | 14 ms | 1920 KB | Output is correct |
41 | Correct | 12 ms | 1968 KB | Output is correct |
42 | Correct | 69 ms | 1792 KB | Output is correct |
43 | Correct | 60 ms | 1764 KB | Output is correct |
44 | Correct | 59 ms | 1680 KB | Output is correct |
45 | Correct | 10 ms | 1920 KB | Output is correct |
46 | Correct | 11 ms | 1920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1024 KB | Output is correct |
2 | Correct | 3 ms | 1024 KB | Output is correct |
3 | Correct | 3 ms | 1024 KB | Output is correct |
4 | Correct | 3 ms | 1024 KB | Output is correct |
5 | Correct | 3 ms | 1024 KB | Output is correct |
6 | Correct | 3 ms | 1024 KB | Output is correct |
7 | Correct | 3 ms | 1024 KB | Output is correct |
8 | Correct | 3 ms | 1024 KB | Output is correct |
9 | Correct | 3 ms | 1024 KB | Output is correct |
10 | Correct | 4 ms | 1024 KB | Output is correct |
11 | Correct | 4 ms | 1024 KB | Output is correct |
12 | Correct | 3 ms | 1024 KB | Output is correct |
13 | Correct | 3 ms | 1024 KB | Output is correct |
14 | Correct | 4 ms | 1024 KB | Output is correct |
15 | Correct | 4 ms | 1024 KB | Output is correct |
16 | Correct | 3 ms | 1024 KB | Output is correct |
17 | Correct | 5 ms | 1152 KB | Output is correct |
18 | Correct | 3 ms | 1024 KB | Output is correct |
19 | Correct | 4 ms | 1152 KB | Output is correct |
20 | Correct | 8 ms | 1280 KB | Output is correct |
21 | Correct | 3 ms | 1024 KB | Output is correct |
22 | Correct | 3 ms | 1152 KB | Output is correct |
23 | Correct | 4 ms | 1152 KB | Output is correct |
24 | Correct | 3 ms | 1152 KB | Output is correct |
25 | Correct | 5 ms | 1280 KB | Output is correct |
26 | Correct | 6 ms | 1152 KB | Output is correct |
27 | Correct | 5 ms | 1152 KB | Output is correct |
28 | Correct | 5 ms | 1152 KB | Output is correct |
29 | Correct | 4 ms | 1280 KB | Output is correct |
30 | Correct | 4 ms | 1280 KB | Output is correct |
31 | Correct | 5 ms | 1280 KB | Output is correct |
32 | Correct | 3 ms | 1280 KB | Output is correct |
33 | Correct | 5 ms | 1408 KB | Output is correct |
34 | Correct | 5 ms | 1536 KB | Output is correct |
35 | Correct | 14 ms | 1792 KB | Output is correct |
36 | Correct | 5 ms | 1152 KB | Output is correct |
37 | Correct | 10 ms | 1664 KB | Output is correct |
38 | Correct | 12 ms | 1920 KB | Output is correct |
39 | Correct | 14 ms | 1920 KB | Output is correct |
40 | Correct | 14 ms | 2048 KB | Output is correct |
41 | Correct | 15 ms | 1920 KB | Output is correct |
42 | Correct | 61 ms | 1792 KB | Output is correct |
43 | Correct | 57 ms | 1664 KB | Output is correct |
44 | Correct | 62 ms | 1644 KB | Output is correct |
45 | Correct | 10 ms | 1920 KB | Output is correct |
46 | Correct | 11 ms | 1920 KB | Output is correct |
47 | Correct | 20 ms | 3068 KB | Output is correct |
48 | Correct | 10 ms | 2048 KB | Output is correct |
49 | Correct | 10 ms | 2048 KB | Output is correct |
50 | Correct | 8 ms | 1792 KB | Output is correct |
51 | Correct | 40 ms | 4660 KB | Output is correct |
52 | Correct | 41 ms | 3608 KB | Output is correct |
53 | Correct | 25 ms | 3572 KB | Output is correct |
54 | Correct | 5 ms | 1664 KB | Output is correct |
55 | Correct | 5 ms | 1664 KB | Output is correct |
56 | Correct | 894 ms | 3324 KB | Output is correct |
57 | Correct | 63 ms | 5624 KB | Output is correct |
58 | Correct | 808 ms | 2048 KB | Output is correct |
59 | Correct | 745 ms | 2148 KB | Output is correct |
60 | Correct | 729 ms | 2240 KB | Output is correct |
61 | Correct | 664 ms | 2252 KB | Output is correct |
62 | Correct | 14 ms | 2788 KB | Output is correct |
63 | Correct | 33 ms | 4088 KB | Output is correct |
64 | Correct | 31 ms | 4088 KB | Output is correct |
65 | Correct | 35 ms | 4088 KB | Output is correct |
66 | Correct | 53 ms | 6256 KB | Output is correct |
67 | Correct | 51 ms | 6100 KB | Output is correct |