# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31723 | 2017-09-02T16:18:38 Z | top34051 | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 339 ms | 262144 KB |
#include<bits/stdc++.h> using namespace std; #define inf 1e9 struct node { int x,val; node(int _x = 0,int _val = 0) { x = _x; val = _val; } bool operator < (node a) const { return a.val<val; } }; int n,m,st,ft; int mem[2005]; vector<pair<int,int> > from[2005]; priority_queue<node> heap; main() { int i,x,y,pos,val; scanf("%d%d",&n,&m); for(i=0;i<m;i++) { scanf("%d%d",&pos,&val); if(i==0) st = pos; if(i==1) ft = pos; for(x=0;x<n;x++) if(abs(pos-x)%val==0) from[pos].push_back({x,abs(pos-x)/val}); } for(i=0;i<n;i++) mem[i] = inf; mem[st] = 0; heap.push(node(st,0)); while(!heap.empty()) { x = heap.top().x; heap.pop(); for(i=0;i<from[x].size();i++) { y = from[x][i].first; val = from[x][i].second; if(mem[y] > mem[x] + val) { mem[y] = mem[x] + val; heap.push(node(y,mem[y])); } } } if(mem[ft]==inf) printf("-1"); else printf("%d",mem[ft]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2068 KB | Output is correct |
2 | Correct | 0 ms | 2068 KB | Output is correct |
3 | Correct | 0 ms | 2068 KB | Output is correct |
4 | Correct | 0 ms | 2068 KB | Output is correct |
5 | Correct | 0 ms | 2068 KB | Output is correct |
6 | Correct | 0 ms | 2068 KB | Output is correct |
7 | Correct | 0 ms | 2068 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2068 KB | Output is correct |
2 | Correct | 0 ms | 2068 KB | Output is correct |
3 | Correct | 0 ms | 2068 KB | Output is correct |
4 | Correct | 0 ms | 2068 KB | Output is correct |
5 | Correct | 0 ms | 2068 KB | Output is correct |
6 | Correct | 0 ms | 2068 KB | Output is correct |
7 | Correct | 0 ms | 2068 KB | Output is correct |
8 | Correct | 0 ms | 2068 KB | Output is correct |
9 | Correct | 0 ms | 2068 KB | Output is correct |
10 | Correct | 0 ms | 2068 KB | Output is correct |
11 | Correct | 0 ms | 2200 KB | Output is correct |
12 | Correct | 3 ms | 5228 KB | Output is correct |
13 | Correct | 3 ms | 5232 KB | Output is correct |
14 | Correct | 0 ms | 2200 KB | Output is correct |
15 | Correct | 0 ms | 2200 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2068 KB | Output is correct |
2 | Correct | 0 ms | 2068 KB | Output is correct |
3 | Correct | 0 ms | 2068 KB | Output is correct |
4 | Correct | 0 ms | 2068 KB | Output is correct |
5 | Correct | 0 ms | 2068 KB | Output is correct |
6 | Correct | 0 ms | 2068 KB | Output is correct |
7 | Correct | 0 ms | 2068 KB | Output is correct |
8 | Correct | 0 ms | 2068 KB | Output is correct |
9 | Correct | 0 ms | 2068 KB | Output is correct |
10 | Correct | 0 ms | 2068 KB | Output is correct |
11 | Correct | 0 ms | 2200 KB | Output is correct |
12 | Correct | 3 ms | 5228 KB | Output is correct |
13 | Correct | 3 ms | 5232 KB | Output is correct |
14 | Correct | 0 ms | 2200 KB | Output is correct |
15 | Correct | 0 ms | 2200 KB | Output is correct |
16 | Correct | 0 ms | 2200 KB | Output is correct |
17 | Correct | 6 ms | 2332 KB | Output is correct |
18 | Correct | 6 ms | 2200 KB | Output is correct |
19 | Correct | 6 ms | 2204 KB | Output is correct |
20 | Correct | 46 ms | 34096 KB | Output is correct |
21 | Correct | 3 ms | 2068 KB | Output is correct |
22 | Correct | 6 ms | 2200 KB | Output is correct |
23 | Correct | 6 ms | 2200 KB | Output is correct |
24 | Correct | 16 ms | 2340 KB | Output is correct |
25 | Correct | 19 ms | 2208 KB | Output is correct |
26 | Correct | 59 ms | 51440 KB | Output is correct |
27 | Correct | 66 ms | 51360 KB | Output is correct |
28 | Correct | 19 ms | 2332 KB | Output is correct |
29 | Correct | 9 ms | 3056 KB | Output is correct |
30 | Correct | 3 ms | 2516 KB | Output is correct |
31 | Correct | 9 ms | 2644 KB | Output is correct |
32 | Correct | 3 ms | 2512 KB | Output is correct |
33 | Correct | 23 ms | 3704 KB | Output is correct |
34 | Correct | 23 ms | 3792 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2068 KB | Output is correct |
2 | Correct | 0 ms | 2068 KB | Output is correct |
3 | Correct | 0 ms | 2068 KB | Output is correct |
4 | Correct | 0 ms | 2068 KB | Output is correct |
5 | Correct | 0 ms | 2068 KB | Output is correct |
6 | Correct | 0 ms | 2068 KB | Output is correct |
7 | Correct | 0 ms | 2068 KB | Output is correct |
8 | Correct | 0 ms | 2068 KB | Output is correct |
9 | Correct | 0 ms | 2068 KB | Output is correct |
10 | Correct | 0 ms | 2068 KB | Output is correct |
11 | Correct | 0 ms | 2200 KB | Output is correct |
12 | Correct | 3 ms | 5228 KB | Output is correct |
13 | Correct | 3 ms | 5232 KB | Output is correct |
14 | Correct | 0 ms | 2200 KB | Output is correct |
15 | Correct | 0 ms | 2200 KB | Output is correct |
16 | Correct | 0 ms | 2200 KB | Output is correct |
17 | Correct | 6 ms | 2332 KB | Output is correct |
18 | Correct | 9 ms | 2200 KB | Output is correct |
19 | Correct | 3 ms | 2204 KB | Output is correct |
20 | Correct | 49 ms | 34096 KB | Output is correct |
21 | Correct | 0 ms | 2068 KB | Output is correct |
22 | Correct | 6 ms | 2200 KB | Output is correct |
23 | Correct | 3 ms | 2200 KB | Output is correct |
24 | Correct | 16 ms | 2340 KB | Output is correct |
25 | Correct | 19 ms | 2208 KB | Output is correct |
26 | Correct | 56 ms | 51440 KB | Output is correct |
27 | Correct | 63 ms | 51360 KB | Output is correct |
28 | Correct | 19 ms | 2332 KB | Output is correct |
29 | Correct | 3 ms | 3056 KB | Output is correct |
30 | Correct | 3 ms | 2516 KB | Output is correct |
31 | Correct | 6 ms | 2644 KB | Output is correct |
32 | Correct | 3 ms | 2512 KB | Output is correct |
33 | Correct | 19 ms | 3704 KB | Output is correct |
34 | Correct | 23 ms | 3792 KB | Output is correct |
35 | Correct | 189 ms | 3952 KB | Output is correct |
36 | Correct | 26 ms | 2332 KB | Output is correct |
37 | Correct | 189 ms | 5708 KB | Output is correct |
38 | Correct | 289 ms | 5188 KB | Output is correct |
39 | Correct | 339 ms | 5460 KB | Output is correct |
40 | Correct | 299 ms | 5316 KB | Output is correct |
41 | Correct | 289 ms | 5248 KB | Output is correct |
42 | Memory limit exceeded | 199 ms | 262144 KB | Memory limit exceeded |
43 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2068 KB | Output is correct |
2 | Correct | 0 ms | 2068 KB | Output is correct |
3 | Correct | 0 ms | 2068 KB | Output is correct |
4 | Correct | 0 ms | 2068 KB | Output is correct |
5 | Correct | 0 ms | 2068 KB | Output is correct |
6 | Correct | 0 ms | 2068 KB | Output is correct |
7 | Correct | 0 ms | 2068 KB | Output is correct |
8 | Correct | 0 ms | 2068 KB | Output is correct |
9 | Correct | 0 ms | 2068 KB | Output is correct |
10 | Correct | 0 ms | 2068 KB | Output is correct |
11 | Correct | 0 ms | 2200 KB | Output is correct |
12 | Correct | 3 ms | 5228 KB | Output is correct |
13 | Correct | 0 ms | 5232 KB | Output is correct |
14 | Correct | 0 ms | 2200 KB | Output is correct |
15 | Correct | 0 ms | 2200 KB | Output is correct |
16 | Correct | 0 ms | 2200 KB | Output is correct |
17 | Correct | 6 ms | 2332 KB | Output is correct |
18 | Correct | 6 ms | 2200 KB | Output is correct |
19 | Correct | 3 ms | 2204 KB | Output is correct |
20 | Correct | 73 ms | 34096 KB | Output is correct |
21 | Correct | 3 ms | 2068 KB | Output is correct |
22 | Correct | 6 ms | 2200 KB | Output is correct |
23 | Correct | 6 ms | 2200 KB | Output is correct |
24 | Correct | 16 ms | 2340 KB | Output is correct |
25 | Correct | 19 ms | 2208 KB | Output is correct |
26 | Correct | 63 ms | 51440 KB | Output is correct |
27 | Correct | 66 ms | 51360 KB | Output is correct |
28 | Correct | 16 ms | 2332 KB | Output is correct |
29 | Correct | 9 ms | 3056 KB | Output is correct |
30 | Correct | 0 ms | 2516 KB | Output is correct |
31 | Correct | 6 ms | 2644 KB | Output is correct |
32 | Correct | 3 ms | 2512 KB | Output is correct |
33 | Correct | 16 ms | 3704 KB | Output is correct |
34 | Correct | 13 ms | 3792 KB | Output is correct |
35 | Correct | 179 ms | 3952 KB | Output is correct |
36 | Correct | 26 ms | 2332 KB | Output is correct |
37 | Correct | 186 ms | 5708 KB | Output is correct |
38 | Correct | 296 ms | 5188 KB | Output is correct |
39 | Correct | 309 ms | 5460 KB | Output is correct |
40 | Correct | 296 ms | 5316 KB | Output is correct |
41 | Correct | 333 ms | 5248 KB | Output is correct |
42 | Memory limit exceeded | 236 ms | 262144 KB | Memory limit exceeded |
43 | Halted | 0 ms | 0 KB | - |