# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
520872 | 2022-01-31T10:32:23 Z | knon0501 | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 1000 ms | 2052 KB |
#include <bits/stdc++.h> using namespace std; const int INF=1e9; int dist[30005]; int vis[30005]; vector<int> a[30005]; int n,m; int main(){ //freopen("input.txt","r",stdin); cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>m; int t; int k; for(int i=0 ; i<m ;i++){ int x,y; cin>>x>>y; if(i==0)k=x; if(i==1)t=x; a[x].emplace_back(y); } for(int i=0 ; i<n ; i++)dist[i]=INF; dist[k]=0; for(int i=0 ; i<n ; i++){ int v=-1; for(int j=0 ; j<n ; j++){ if(vis[j]==0) if(v==-1 || dist[j]<dist[v]) { v=j; } } if(dist[v]==INF){ cout<<-1; return 0; } if(v==t){ cout<<dist[v]<<"\n"; return 0; } vis[v]=1; for(auto &x: a[v]){ int cnt=0; for(int j=v+x; j<n ; j+=x) dist[j]=min(dist[j],dist[v]+(++cnt)); cnt=0; for(int j=v-x ; j>=0 ; j-=x) dist[j]=min(dist[j],dist[v]+(++cnt)); } } if(dist[t]==INF) cout<<-1; else cout<<dist[t]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 972 KB | Output is correct |
2 | Correct | 1 ms | 972 KB | Output is correct |
3 | Correct | 1 ms | 972 KB | Output is correct |
4 | Correct | 1 ms | 1028 KB | Output is correct |
5 | Correct | 1 ms | 972 KB | Output is correct |
6 | Correct | 1 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 972 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 972 KB | Output is correct |
2 | Correct | 1 ms | 972 KB | Output is correct |
3 | Correct | 1 ms | 1100 KB | Output is correct |
4 | Correct | 1 ms | 972 KB | Output is correct |
5 | Correct | 1 ms | 972 KB | Output is correct |
6 | Correct | 1 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 972 KB | Output is correct |
8 | Correct | 1 ms | 1032 KB | Output is correct |
9 | Correct | 1 ms | 972 KB | Output is correct |
10 | Correct | 1 ms | 972 KB | Output is correct |
11 | Correct | 1 ms | 972 KB | Output is correct |
12 | Correct | 1 ms | 972 KB | Output is correct |
13 | Correct | 2 ms | 1028 KB | Output is correct |
14 | Correct | 1 ms | 972 KB | Output is correct |
15 | Correct | 1 ms | 972 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 972 KB | Output is correct |
2 | Correct | 1 ms | 1028 KB | Output is correct |
3 | Correct | 1 ms | 972 KB | Output is correct |
4 | Correct | 1 ms | 972 KB | Output is correct |
5 | Correct | 1 ms | 972 KB | Output is correct |
6 | Correct | 1 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 972 KB | Output is correct |
8 | Correct | 1 ms | 972 KB | Output is correct |
9 | Correct | 1 ms | 972 KB | Output is correct |
10 | Correct | 1 ms | 972 KB | Output is correct |
11 | Correct | 1 ms | 1032 KB | Output is correct |
12 | Correct | 1 ms | 1036 KB | Output is correct |
13 | Correct | 2 ms | 972 KB | Output is correct |
14 | Correct | 1 ms | 972 KB | Output is correct |
15 | Correct | 1 ms | 972 KB | Output is correct |
16 | Correct | 1 ms | 972 KB | Output is correct |
17 | Correct | 2 ms | 1040 KB | Output is correct |
18 | Correct | 1 ms | 972 KB | Output is correct |
19 | Correct | 1 ms | 972 KB | Output is correct |
20 | Correct | 20 ms | 1100 KB | Output is correct |
21 | Correct | 1 ms | 1024 KB | Output is correct |
22 | Correct | 1 ms | 972 KB | Output is correct |
23 | Correct | 6 ms | 1040 KB | Output is correct |
24 | Correct | 8 ms | 1104 KB | Output is correct |
25 | Correct | 4 ms | 1100 KB | Output is correct |
26 | Correct | 7 ms | 972 KB | Output is correct |
27 | Correct | 7 ms | 1036 KB | Output is correct |
28 | Correct | 9 ms | 1100 KB | Output is correct |
29 | Correct | 8 ms | 1032 KB | Output is correct |
30 | Correct | 8 ms | 1028 KB | Output is correct |
31 | Correct | 8 ms | 972 KB | Output is correct |
32 | Correct | 8 ms | 972 KB | Output is correct |
33 | Correct | 9 ms | 1036 KB | Output is correct |
34 | Correct | 9 ms | 972 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 972 KB | Output is correct |
2 | Correct | 1 ms | 972 KB | Output is correct |
3 | Correct | 1 ms | 972 KB | Output is correct |
4 | Correct | 1 ms | 972 KB | Output is correct |
5 | Correct | 1 ms | 972 KB | Output is correct |
6 | Correct | 1 ms | 972 KB | Output is correct |
7 | Correct | 1 ms | 972 KB | Output is correct |
8 | Correct | 1 ms | 972 KB | Output is correct |
9 | Correct | 1 ms | 972 KB | Output is correct |
10 | Correct | 1 ms | 972 KB | Output is correct |
11 | Correct | 1 ms | 1048 KB | Output is correct |
12 | Correct | 1 ms | 1036 KB | Output is correct |
13 | Correct | 2 ms | 972 KB | Output is correct |
14 | Correct | 1 ms | 972 KB | Output is correct |
15 | Correct | 1 ms | 1036 KB | Output is correct |
16 | Correct | 1 ms | 1032 KB | Output is correct |
17 | Correct | 2 ms | 1036 KB | Output is correct |
18 | Correct | 1 ms | 972 KB | Output is correct |
19 | Correct | 1 ms | 972 KB | Output is correct |
20 | Correct | 21 ms | 1028 KB | Output is correct |
21 | Correct | 1 ms | 972 KB | Output is correct |
22 | Correct | 1 ms | 972 KB | Output is correct |
23 | Correct | 6 ms | 1032 KB | Output is correct |
24 | Correct | 7 ms | 1100 KB | Output is correct |
25 | Correct | 3 ms | 1064 KB | Output is correct |
26 | Correct | 7 ms | 1044 KB | Output is correct |
27 | Correct | 9 ms | 1100 KB | Output is correct |
28 | Correct | 9 ms | 1100 KB | Output is correct |
29 | Correct | 9 ms | 972 KB | Output is correct |
30 | Correct | 8 ms | 1024 KB | Output is correct |
31 | Correct | 8 ms | 1052 KB | Output is correct |
32 | Correct | 8 ms | 1100 KB | Output is correct |
33 | Correct | 8 ms | 1040 KB | Output is correct |
34 | Correct | 8 ms | 972 KB | Output is correct |
35 | Correct | 9 ms | 1416 KB | Output is correct |
36 | Correct | 2 ms | 1100 KB | Output is correct |
37 | Correct | 10 ms | 1356 KB | Output is correct |
38 | Correct | 9 ms | 1412 KB | Output is correct |
39 | Correct | 8 ms | 1424 KB | Output is correct |
40 | Correct | 7 ms | 1512 KB | Output is correct |
41 | Correct | 11 ms | 1580 KB | Output is correct |
42 | Correct | 13 ms | 1484 KB | Output is correct |
43 | Correct | 11 ms | 1484 KB | Output is correct |
44 | Correct | 207 ms | 1468 KB | Output is correct |
45 | Correct | 13 ms | 1348 KB | Output is correct |
46 | Correct | 13 ms | 1464 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1028 KB | Output is correct |
2 | Correct | 1 ms | 972 KB | Output is correct |
3 | Correct | 1 ms | 972 KB | Output is correct |
4 | Correct | 1 ms | 972 KB | Output is correct |
5 | Correct | 1 ms | 1028 KB | Output is correct |
6 | Correct | 1 ms | 1100 KB | Output is correct |
7 | Correct | 1 ms | 972 KB | Output is correct |
8 | Correct | 1 ms | 972 KB | Output is correct |
9 | Correct | 1 ms | 1024 KB | Output is correct |
10 | Correct | 1 ms | 1032 KB | Output is correct |
11 | Correct | 1 ms | 972 KB | Output is correct |
12 | Correct | 1 ms | 1040 KB | Output is correct |
13 | Correct | 2 ms | 972 KB | Output is correct |
14 | Correct | 1 ms | 972 KB | Output is correct |
15 | Correct | 1 ms | 1036 KB | Output is correct |
16 | Correct | 1 ms | 1036 KB | Output is correct |
17 | Correct | 2 ms | 972 KB | Output is correct |
18 | Correct | 1 ms | 972 KB | Output is correct |
19 | Correct | 2 ms | 972 KB | Output is correct |
20 | Correct | 20 ms | 1124 KB | Output is correct |
21 | Correct | 1 ms | 972 KB | Output is correct |
22 | Correct | 1 ms | 972 KB | Output is correct |
23 | Correct | 5 ms | 972 KB | Output is correct |
24 | Correct | 8 ms | 1100 KB | Output is correct |
25 | Correct | 3 ms | 1100 KB | Output is correct |
26 | Correct | 7 ms | 1080 KB | Output is correct |
27 | Correct | 8 ms | 1076 KB | Output is correct |
28 | Correct | 11 ms | 1100 KB | Output is correct |
29 | Correct | 8 ms | 1032 KB | Output is correct |
30 | Correct | 8 ms | 972 KB | Output is correct |
31 | Correct | 8 ms | 1024 KB | Output is correct |
32 | Correct | 8 ms | 972 KB | Output is correct |
33 | Correct | 8 ms | 1040 KB | Output is correct |
34 | Correct | 8 ms | 972 KB | Output is correct |
35 | Correct | 9 ms | 1424 KB | Output is correct |
36 | Correct | 3 ms | 1100 KB | Output is correct |
37 | Correct | 10 ms | 1356 KB | Output is correct |
38 | Correct | 9 ms | 1420 KB | Output is correct |
39 | Correct | 9 ms | 1404 KB | Output is correct |
40 | Correct | 9 ms | 1484 KB | Output is correct |
41 | Correct | 8 ms | 1456 KB | Output is correct |
42 | Correct | 10 ms | 1408 KB | Output is correct |
43 | Correct | 11 ms | 1484 KB | Output is correct |
44 | Correct | 203 ms | 1480 KB | Output is correct |
45 | Correct | 13 ms | 1356 KB | Output is correct |
46 | Correct | 15 ms | 1356 KB | Output is correct |
47 | Correct | 163 ms | 1688 KB | Output is correct |
48 | Correct | 6 ms | 1740 KB | Output is correct |
49 | Correct | 8 ms | 1740 KB | Output is correct |
50 | Correct | 5 ms | 1612 KB | Output is correct |
51 | Execution timed out | 1085 ms | 2052 KB | Time limit exceeded |
52 | Halted | 0 ms | 0 KB | - |