# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
45443 | 2018-04-14T05:01:35 Z | RayaBurong25_1 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 1000 ms | 33460 KB |
#include <stdio.h> #include <vector> #include <queue> #define INF 1000000007 int B[30005], P[30005]; std::vector<std::pair<int, int> > AdjList[30005]; int abs(int a) { return (a < 0)?-a:a; } int Min[30005]; typedef struct node node; struct node { int u, w; }; bool operator<(node a, node b) { return (a.w > b.w); } std::priority_queue<node> Q; int main() { int N, M; scanf("%d %d", &N, &M); int i, j; for (i = 0; i < M; i++) scanf("%d %d", &B[i], &P[i]); for (i = 0; i < M; i++) { for (j = 0; j < M; j++) { if (i == j) continue; if (abs(B[i] - B[j])%P[i] == 0) AdjList[i].push_back({j, abs(B[i] - B[j])/P[i]}); } Min[i] = INF; } Min[0] = 0; Q.push({0, 0}); node p; int v, w, s; while (!Q.empty()) { do { p = Q.top(); Q.pop(); } while (Min[p.u] < p.w); if (p.u == 1) { printf("%d", p.w); return 0; } s = AdjList[p.u].size(); for (i = 0; i < s; i++) { v = AdjList[p.u][i].first; w = AdjList[p.u][i].second; if (p.w + w < Min[v]) { Min[v] = p.w + w; Q.push({v, Min[v]}); } } } printf("-1"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1016 KB | Output is correct |
2 | Correct | 2 ms | 1016 KB | Output is correct |
3 | Correct | 2 ms | 1072 KB | Output is correct |
4 | Correct | 2 ms | 1072 KB | Output is correct |
5 | Correct | 2 ms | 1072 KB | Output is correct |
6 | Correct | 2 ms | 1280 KB | Output is correct |
7 | Correct | 2 ms | 1280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1280 KB | Output is correct |
2 | Correct | 2 ms | 1280 KB | Output is correct |
3 | Correct | 2 ms | 1280 KB | Output is correct |
4 | Correct | 2 ms | 1280 KB | Output is correct |
5 | Correct | 3 ms | 1280 KB | Output is correct |
6 | Correct | 2 ms | 1280 KB | Output is correct |
7 | Correct | 2 ms | 1392 KB | Output is correct |
8 | Correct | 2 ms | 1392 KB | Output is correct |
9 | Correct | 2 ms | 1392 KB | Output is correct |
10 | Correct | 5 ms | 1392 KB | Output is correct |
11 | Correct | 27 ms | 3452 KB | Output is correct |
12 | Correct | 76 ms | 33192 KB | Output is correct |
13 | Correct | 82 ms | 33448 KB | Output is correct |
14 | Correct | 27 ms | 33448 KB | Output is correct |
15 | Correct | 26 ms | 33448 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 33448 KB | Output is correct |
2 | Correct | 2 ms | 33448 KB | Output is correct |
3 | Correct | 2 ms | 33448 KB | Output is correct |
4 | Correct | 3 ms | 33448 KB | Output is correct |
5 | Correct | 2 ms | 33448 KB | Output is correct |
6 | Correct | 2 ms | 33448 KB | Output is correct |
7 | Correct | 2 ms | 33448 KB | Output is correct |
8 | Correct | 2 ms | 33448 KB | Output is correct |
9 | Correct | 2 ms | 33448 KB | Output is correct |
10 | Correct | 4 ms | 33448 KB | Output is correct |
11 | Correct | 27 ms | 33448 KB | Output is correct |
12 | Correct | 72 ms | 33448 KB | Output is correct |
13 | Correct | 80 ms | 33448 KB | Output is correct |
14 | Correct | 26 ms | 33448 KB | Output is correct |
15 | Correct | 25 ms | 33448 KB | Output is correct |
16 | Correct | 6 ms | 33448 KB | Output is correct |
17 | Correct | 19 ms | 33448 KB | Output is correct |
18 | Correct | 7 ms | 33448 KB | Output is correct |
19 | Correct | 4 ms | 33448 KB | Output is correct |
20 | Correct | 93 ms | 33460 KB | Output is correct |
21 | Correct | 9 ms | 33460 KB | Output is correct |
22 | Correct | 5 ms | 33460 KB | Output is correct |
23 | Correct | 7 ms | 33460 KB | Output is correct |
24 | Correct | 19 ms | 33460 KB | Output is correct |
25 | Correct | 21 ms | 33460 KB | Output is correct |
26 | Correct | 68 ms | 33460 KB | Output is correct |
27 | Correct | 76 ms | 33460 KB | Output is correct |
28 | Correct | 21 ms | 33460 KB | Output is correct |
29 | Correct | 6 ms | 33460 KB | Output is correct |
30 | Correct | 3 ms | 33460 KB | Output is correct |
31 | Correct | 4 ms | 33460 KB | Output is correct |
32 | Correct | 4 ms | 33460 KB | Output is correct |
33 | Correct | 35 ms | 33460 KB | Output is correct |
34 | Correct | 27 ms | 33460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 33460 KB | Output is correct |
2 | Correct | 2 ms | 33460 KB | Output is correct |
3 | Correct | 2 ms | 33460 KB | Output is correct |
4 | Correct | 2 ms | 33460 KB | Output is correct |
5 | Correct | 2 ms | 33460 KB | Output is correct |
6 | Correct | 2 ms | 33460 KB | Output is correct |
7 | Correct | 2 ms | 33460 KB | Output is correct |
8 | Correct | 2 ms | 33460 KB | Output is correct |
9 | Correct | 2 ms | 33460 KB | Output is correct |
10 | Correct | 19 ms | 33460 KB | Output is correct |
11 | Correct | 27 ms | 33460 KB | Output is correct |
12 | Correct | 74 ms | 33460 KB | Output is correct |
13 | Correct | 84 ms | 33460 KB | Output is correct |
14 | Correct | 26 ms | 33460 KB | Output is correct |
15 | Correct | 25 ms | 33460 KB | Output is correct |
16 | Correct | 8 ms | 33460 KB | Output is correct |
17 | Correct | 19 ms | 33460 KB | Output is correct |
18 | Correct | 7 ms | 33460 KB | Output is correct |
19 | Correct | 5 ms | 33460 KB | Output is correct |
20 | Correct | 83 ms | 33460 KB | Output is correct |
21 | Correct | 9 ms | 33460 KB | Output is correct |
22 | Correct | 6 ms | 33460 KB | Output is correct |
23 | Correct | 7 ms | 33460 KB | Output is correct |
24 | Correct | 20 ms | 33460 KB | Output is correct |
25 | Correct | 21 ms | 33460 KB | Output is correct |
26 | Correct | 71 ms | 33460 KB | Output is correct |
27 | Correct | 76 ms | 33460 KB | Output is correct |
28 | Correct | 21 ms | 33460 KB | Output is correct |
29 | Correct | 6 ms | 33460 KB | Output is correct |
30 | Correct | 3 ms | 33460 KB | Output is correct |
31 | Correct | 4 ms | 33460 KB | Output is correct |
32 | Correct | 4 ms | 33460 KB | Output is correct |
33 | Correct | 26 ms | 33460 KB | Output is correct |
34 | Correct | 27 ms | 33460 KB | Output is correct |
35 | Execution timed out | 1087 ms | 33460 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 33460 KB | Output is correct |
2 | Correct | 2 ms | 33460 KB | Output is correct |
3 | Correct | 2 ms | 33460 KB | Output is correct |
4 | Correct | 2 ms | 33460 KB | Output is correct |
5 | Correct | 2 ms | 33460 KB | Output is correct |
6 | Correct | 2 ms | 33460 KB | Output is correct |
7 | Correct | 2 ms | 33460 KB | Output is correct |
8 | Correct | 2 ms | 33460 KB | Output is correct |
9 | Correct | 2 ms | 33460 KB | Output is correct |
10 | Correct | 3 ms | 33460 KB | Output is correct |
11 | Correct | 27 ms | 33460 KB | Output is correct |
12 | Correct | 73 ms | 33460 KB | Output is correct |
13 | Correct | 81 ms | 33460 KB | Output is correct |
14 | Correct | 29 ms | 33460 KB | Output is correct |
15 | Correct | 26 ms | 33460 KB | Output is correct |
16 | Correct | 9 ms | 33460 KB | Output is correct |
17 | Correct | 18 ms | 33460 KB | Output is correct |
18 | Correct | 10 ms | 33460 KB | Output is correct |
19 | Correct | 4 ms | 33460 KB | Output is correct |
20 | Correct | 79 ms | 33460 KB | Output is correct |
21 | Correct | 9 ms | 33460 KB | Output is correct |
22 | Correct | 5 ms | 33460 KB | Output is correct |
23 | Correct | 7 ms | 33460 KB | Output is correct |
24 | Correct | 18 ms | 33460 KB | Output is correct |
25 | Correct | 20 ms | 33460 KB | Output is correct |
26 | Correct | 69 ms | 33460 KB | Output is correct |
27 | Correct | 78 ms | 33460 KB | Output is correct |
28 | Correct | 21 ms | 33460 KB | Output is correct |
29 | Correct | 6 ms | 33460 KB | Output is correct |
30 | Correct | 3 ms | 33460 KB | Output is correct |
31 | Correct | 6 ms | 33460 KB | Output is correct |
32 | Correct | 4 ms | 33460 KB | Output is correct |
33 | Correct | 28 ms | 33460 KB | Output is correct |
34 | Correct | 26 ms | 33460 KB | Output is correct |
35 | Execution timed out | 1088 ms | 33460 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |