# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995496 | 2024-06-09T07:25:56 Z | Baytoro | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1000 ms | 2444 KB |
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second #define pb push_back //#define int long long #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } #define ll long long const int N=3e4+5; vector<int> g[N]; bool used[N]; int dist[N]; int n,m; void solve(){ int n,m;cin>>n>>m; vector<int> b(m),p(m); for(int i=0;i<N;i++) dist[i]=1e9; for(int i=0;i<m;i++){ cin>>b[i]>>p[i]; g[b[i]].pb(p[i]); } int node=b[0]; dist[node]=0; while(!used[b[1]] && node!=-1){ used[node]=1; for(auto it: g[node]){ for(int j=1;node+j*it<n;j++){ dist[node+j*it]=min(dist[node+j*it],dist[node]+j); } for(int j=1;node-j*it>=0;j++){ dist[node-j*it]=min(dist[node-j*it],dist[node]+j); } } node=-1; for(int i=0;i<n;i++){ if(used[i]) continue; if(dist[i]==1e9) continue; if(node==-1 || dist[node]>dist[i]) node=i; } } if(dist[b[1]]==1e9) dist[b[1]]=-1; cout<<dist[b[1]]; } signed main(){ //fopn("paint"); int t=1;//cin>>t; while(t--) solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
3 | Correct | 0 ms | 1116 KB | Output is correct |
4 | Correct | 1 ms | 1116 KB | Output is correct |
5 | Correct | 1 ms | 1116 KB | Output is correct |
6 | Correct | 1 ms | 1116 KB | Output is correct |
7 | Correct | 1 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1112 KB | Output is correct |
3 | Correct | 1 ms | 1112 KB | Output is correct |
4 | Correct | 1 ms | 1116 KB | Output is correct |
5 | Correct | 1 ms | 1148 KB | Output is correct |
6 | Correct | 1 ms | 1116 KB | Output is correct |
7 | Correct | 1 ms | 1116 KB | Output is correct |
8 | Correct | 1 ms | 1116 KB | Output is correct |
9 | Correct | 0 ms | 1116 KB | Output is correct |
10 | Correct | 1 ms | 1116 KB | Output is correct |
11 | Correct | 1 ms | 1112 KB | Output is correct |
12 | Correct | 2 ms | 1116 KB | Output is correct |
13 | Correct | 2 ms | 1116 KB | Output is correct |
14 | Correct | 1 ms | 1116 KB | Output is correct |
15 | Correct | 1 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
3 | Correct | 0 ms | 1116 KB | Output is correct |
4 | Correct | 1 ms | 1116 KB | Output is correct |
5 | Correct | 1 ms | 1116 KB | Output is correct |
6 | Correct | 1 ms | 1116 KB | Output is correct |
7 | Correct | 1 ms | 1112 KB | Output is correct |
8 | Correct | 1 ms | 1368 KB | Output is correct |
9 | Correct | 1 ms | 1116 KB | Output is correct |
10 | Correct | 1 ms | 1116 KB | Output is correct |
11 | Correct | 1 ms | 1368 KB | Output is correct |
12 | Correct | 1 ms | 1116 KB | Output is correct |
13 | Correct | 1 ms | 1116 KB | Output is correct |
14 | Correct | 1 ms | 1116 KB | Output is correct |
15 | Correct | 1 ms | 1156 KB | Output is correct |
16 | Correct | 1 ms | 1116 KB | Output is correct |
17 | Correct | 2 ms | 1116 KB | Output is correct |
18 | Correct | 1 ms | 1116 KB | Output is correct |
19 | Correct | 1 ms | 1116 KB | Output is correct |
20 | Correct | 10 ms | 1112 KB | Output is correct |
21 | Correct | 1 ms | 1116 KB | Output is correct |
22 | Correct | 1 ms | 1116 KB | Output is correct |
23 | Correct | 4 ms | 1116 KB | Output is correct |
24 | Correct | 7 ms | 1116 KB | Output is correct |
25 | Correct | 2 ms | 1116 KB | Output is correct |
26 | Correct | 6 ms | 1312 KB | Output is correct |
27 | Correct | 7 ms | 1112 KB | Output is correct |
28 | Correct | 5 ms | 1348 KB | Output is correct |
29 | Correct | 7 ms | 1116 KB | Output is correct |
30 | Correct | 7 ms | 1268 KB | Output is correct |
31 | Correct | 7 ms | 1116 KB | Output is correct |
32 | Correct | 7 ms | 1272 KB | Output is correct |
33 | Correct | 7 ms | 1116 KB | Output is correct |
34 | Correct | 7 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1112 KB | Output is correct |
3 | Correct | 1 ms | 1116 KB | Output is correct |
4 | Correct | 1 ms | 1116 KB | Output is correct |
5 | Correct | 0 ms | 1116 KB | Output is correct |
6 | Correct | 1 ms | 1116 KB | Output is correct |
7 | Correct | 1 ms | 1116 KB | Output is correct |
8 | Correct | 1 ms | 1116 KB | Output is correct |
9 | Correct | 0 ms | 1116 KB | Output is correct |
10 | Correct | 1 ms | 1116 KB | Output is correct |
11 | Correct | 1 ms | 1116 KB | Output is correct |
12 | Correct | 1 ms | 1116 KB | Output is correct |
13 | Correct | 1 ms | 1116 KB | Output is correct |
14 | Correct | 1 ms | 1116 KB | Output is correct |
15 | Correct | 1 ms | 1116 KB | Output is correct |
16 | Correct | 1 ms | 1116 KB | Output is correct |
17 | Correct | 2 ms | 1312 KB | Output is correct |
18 | Correct | 1 ms | 1116 KB | Output is correct |
19 | Correct | 1 ms | 1116 KB | Output is correct |
20 | Correct | 11 ms | 1164 KB | Output is correct |
21 | Correct | 1 ms | 1116 KB | Output is correct |
22 | Correct | 1 ms | 1116 KB | Output is correct |
23 | Correct | 4 ms | 1112 KB | Output is correct |
24 | Correct | 6 ms | 1116 KB | Output is correct |
25 | Correct | 2 ms | 1116 KB | Output is correct |
26 | Correct | 3 ms | 1116 KB | Output is correct |
27 | Correct | 6 ms | 1316 KB | Output is correct |
28 | Correct | 6 ms | 1112 KB | Output is correct |
29 | Correct | 7 ms | 1116 KB | Output is correct |
30 | Correct | 7 ms | 1116 KB | Output is correct |
31 | Correct | 7 ms | 1116 KB | Output is correct |
32 | Correct | 6 ms | 1276 KB | Output is correct |
33 | Correct | 7 ms | 1116 KB | Output is correct |
34 | Correct | 7 ms | 1304 KB | Output is correct |
35 | Correct | 15 ms | 1884 KB | Output is correct |
36 | Correct | 3 ms | 1372 KB | Output is correct |
37 | Correct | 11 ms | 1572 KB | Output is correct |
38 | Correct | 13 ms | 1944 KB | Output is correct |
39 | Correct | 10 ms | 1884 KB | Output is correct |
40 | Correct | 10 ms | 1808 KB | Output is correct |
41 | Correct | 11 ms | 1884 KB | Output is correct |
42 | Correct | 10 ms | 1944 KB | Output is correct |
43 | Correct | 50 ms | 1960 KB | Output is correct |
44 | Correct | 62 ms | 1884 KB | Output is correct |
45 | Correct | 14 ms | 1884 KB | Output is correct |
46 | Correct | 14 ms | 1916 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 0 ms | 1116 KB | Output is correct |
3 | Correct | 0 ms | 1116 KB | Output is correct |
4 | Correct | 1 ms | 1116 KB | Output is correct |
5 | Correct | 1 ms | 1120 KB | Output is correct |
6 | Correct | 1 ms | 1368 KB | Output is correct |
7 | Correct | 1 ms | 1116 KB | Output is correct |
8 | Correct | 0 ms | 1116 KB | Output is correct |
9 | Correct | 1 ms | 1116 KB | Output is correct |
10 | Correct | 1 ms | 1144 KB | Output is correct |
11 | Correct | 1 ms | 1116 KB | Output is correct |
12 | Correct | 1 ms | 1112 KB | Output is correct |
13 | Correct | 1 ms | 1116 KB | Output is correct |
14 | Correct | 1 ms | 1116 KB | Output is correct |
15 | Correct | 1 ms | 1116 KB | Output is correct |
16 | Correct | 1 ms | 1116 KB | Output is correct |
17 | Correct | 2 ms | 1116 KB | Output is correct |
18 | Correct | 1 ms | 1116 KB | Output is correct |
19 | Correct | 1 ms | 1116 KB | Output is correct |
20 | Correct | 10 ms | 1116 KB | Output is correct |
21 | Correct | 1 ms | 1116 KB | Output is correct |
22 | Correct | 1 ms | 1116 KB | Output is correct |
23 | Correct | 3 ms | 1116 KB | Output is correct |
24 | Correct | 5 ms | 1116 KB | Output is correct |
25 | Correct | 2 ms | 1116 KB | Output is correct |
26 | Correct | 4 ms | 1160 KB | Output is correct |
27 | Correct | 6 ms | 1116 KB | Output is correct |
28 | Correct | 4 ms | 1116 KB | Output is correct |
29 | Correct | 7 ms | 1280 KB | Output is correct |
30 | Correct | 7 ms | 1112 KB | Output is correct |
31 | Correct | 7 ms | 1116 KB | Output is correct |
32 | Correct | 7 ms | 1116 KB | Output is correct |
33 | Correct | 8 ms | 1116 KB | Output is correct |
34 | Correct | 7 ms | 1300 KB | Output is correct |
35 | Correct | 11 ms | 1880 KB | Output is correct |
36 | Correct | 3 ms | 1372 KB | Output is correct |
37 | Correct | 10 ms | 1672 KB | Output is correct |
38 | Correct | 12 ms | 1884 KB | Output is correct |
39 | Correct | 15 ms | 1884 KB | Output is correct |
40 | Correct | 10 ms | 1884 KB | Output is correct |
41 | Correct | 14 ms | 1884 KB | Output is correct |
42 | Correct | 10 ms | 1884 KB | Output is correct |
43 | Correct | 56 ms | 1820 KB | Output is correct |
44 | Correct | 52 ms | 1952 KB | Output is correct |
45 | Correct | 15 ms | 1880 KB | Output is correct |
46 | Correct | 15 ms | 1884 KB | Output is correct |
47 | Correct | 133 ms | 2008 KB | Output is correct |
48 | Correct | 9 ms | 2140 KB | Output is correct |
49 | Correct | 8 ms | 1932 KB | Output is correct |
50 | Correct | 7 ms | 1884 KB | Output is correct |
51 | Execution timed out | 1096 ms | 2444 KB | Time limit exceeded |
52 | Halted | 0 ms | 0 KB | - |