# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41505 | 2018-02-17T15:15:58 Z | fest | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 917 ms | 7784 KB |
// fest #include <bits/stdc++.h> #define pb push_back #define F first #define S second #define y1 dasdasfasfas #define x1 wqdadfasfasfas #define All(c) c.begin(), c.end() #define SZ(A) (int((A).size())) #define umap unordered_map #define FILENAME "" #define __ fflush(stdout) typedef long long ll; typedef long double ld; using namespace std; void FREOPEN() { #ifdef COMP freopen(".in", "r", stdin); freopen("1.out", "w", stdout); #else freopen(FILENAME".in", "r", stdin); freopen(FILENAME".out", "w", stdout); #endif } inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; } const int N = 200500, inf = 1e9 * 2, MOD = (int)1e9 + 7; char CH[N]; const ll INF = 1e18; const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1}; const int dy[] = {0, 0, 1, -1, -1, 1, 1, -1}; int dp[N]; vector<int> have[N]; int main() { int n, m; scanf("%d %d", &n, &m); int start = 0, finish = 0; for (int i = 0; i < m; i++) { int b, p; scanf("%d %d", &b, &p); have[b].pb(p); if (i == 0) start = b; if (i == 1) finish = b; } for (int i = 0; i < n; i++) dp[i] = inf; dp[start] = 0; set<pair<int, int> > s; s.insert({0, start}); while (!s.empty()) { int v = s.begin() -> S; s.erase(s.begin()); for (auto p : have[v]) { for (int mul = 1; v + mul * p < n; mul++) { int u = v + mul * p; if (dp[u] > dp[v] + mul) { s.erase({dp[u], u}); dp[u] = dp[v] + mul; s.insert({dp[u], u}); } } for (int mul = 1; v - mul * p >= 0; mul++) { int u = v - mul * p; if (dp[u] > dp[v] + mul) { s.erase({dp[u], u}); dp[u] = dp[v] + mul; s.insert({dp[u], u}); } } } } if (dp[finish] == inf) dp[finish] = -1; cout << dp[finish]; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4984 KB | Output is correct |
2 | Correct | 5 ms | 5088 KB | Output is correct |
3 | Correct | 6 ms | 5140 KB | Output is correct |
4 | Correct | 5 ms | 5212 KB | Output is correct |
5 | Correct | 5 ms | 5284 KB | Output is correct |
6 | Correct | 5 ms | 5284 KB | Output is correct |
7 | Correct | 5 ms | 5284 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 5284 KB | Output is correct |
2 | Correct | 6 ms | 5284 KB | Output is correct |
3 | Correct | 6 ms | 5284 KB | Output is correct |
4 | Correct | 6 ms | 5292 KB | Output is correct |
5 | Correct | 6 ms | 5292 KB | Output is correct |
6 | Correct | 5 ms | 5292 KB | Output is correct |
7 | Correct | 6 ms | 5292 KB | Output is correct |
8 | Correct | 6 ms | 5292 KB | Output is correct |
9 | Correct | 6 ms | 5292 KB | Output is correct |
10 | Correct | 7 ms | 5292 KB | Output is correct |
11 | Correct | 6 ms | 5292 KB | Output is correct |
12 | Correct | 6 ms | 5292 KB | Output is correct |
13 | Correct | 6 ms | 5292 KB | Output is correct |
14 | Correct | 5 ms | 5292 KB | Output is correct |
15 | Correct | 6 ms | 5292 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5292 KB | Output is correct |
2 | Correct | 6 ms | 5292 KB | Output is correct |
3 | Correct | 5 ms | 5292 KB | Output is correct |
4 | Correct | 6 ms | 5292 KB | Output is correct |
5 | Correct | 5 ms | 5292 KB | Output is correct |
6 | Correct | 6 ms | 5292 KB | Output is correct |
7 | Correct | 5 ms | 5292 KB | Output is correct |
8 | Correct | 5 ms | 5292 KB | Output is correct |
9 | Correct | 5 ms | 5292 KB | Output is correct |
10 | Correct | 5 ms | 5292 KB | Output is correct |
11 | Correct | 6 ms | 5292 KB | Output is correct |
12 | Correct | 6 ms | 5292 KB | Output is correct |
13 | Correct | 6 ms | 5292 KB | Output is correct |
14 | Correct | 6 ms | 5292 KB | Output is correct |
15 | Correct | 6 ms | 5292 KB | Output is correct |
16 | Correct | 6 ms | 5292 KB | Output is correct |
17 | Correct | 6 ms | 5356 KB | Output is correct |
18 | Correct | 5 ms | 5356 KB | Output is correct |
19 | Correct | 5 ms | 5356 KB | Output is correct |
20 | Correct | 11 ms | 5356 KB | Output is correct |
21 | Correct | 6 ms | 5356 KB | Output is correct |
22 | Correct | 5 ms | 5356 KB | Output is correct |
23 | Correct | 6 ms | 5356 KB | Output is correct |
24 | Correct | 7 ms | 5356 KB | Output is correct |
25 | Correct | 7 ms | 5356 KB | Output is correct |
26 | Correct | 10 ms | 5356 KB | Output is correct |
27 | Correct | 10 ms | 5360 KB | Output is correct |
28 | Correct | 6 ms | 5360 KB | Output is correct |
29 | Correct | 9 ms | 5360 KB | Output is correct |
30 | Correct | 7 ms | 5412 KB | Output is correct |
31 | Correct | 8 ms | 5412 KB | Output is correct |
32 | Correct | 7 ms | 5412 KB | Output is correct |
33 | Correct | 10 ms | 5412 KB | Output is correct |
34 | Correct | 10 ms | 5412 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5412 KB | Output is correct |
2 | Correct | 5 ms | 5412 KB | Output is correct |
3 | Correct | 6 ms | 5412 KB | Output is correct |
4 | Correct | 5 ms | 5412 KB | Output is correct |
5 | Correct | 5 ms | 5412 KB | Output is correct |
6 | Correct | 5 ms | 5412 KB | Output is correct |
7 | Correct | 6 ms | 5412 KB | Output is correct |
8 | Correct | 6 ms | 5412 KB | Output is correct |
9 | Correct | 5 ms | 5412 KB | Output is correct |
10 | Correct | 5 ms | 5412 KB | Output is correct |
11 | Correct | 6 ms | 5412 KB | Output is correct |
12 | Correct | 6 ms | 5412 KB | Output is correct |
13 | Correct | 6 ms | 5412 KB | Output is correct |
14 | Correct | 6 ms | 5412 KB | Output is correct |
15 | Correct | 6 ms | 5412 KB | Output is correct |
16 | Correct | 6 ms | 5412 KB | Output is correct |
17 | Correct | 6 ms | 5412 KB | Output is correct |
18 | Correct | 6 ms | 5412 KB | Output is correct |
19 | Correct | 5 ms | 5412 KB | Output is correct |
20 | Correct | 10 ms | 5412 KB | Output is correct |
21 | Correct | 6 ms | 5412 KB | Output is correct |
22 | Correct | 6 ms | 5412 KB | Output is correct |
23 | Correct | 6 ms | 5412 KB | Output is correct |
24 | Correct | 7 ms | 5412 KB | Output is correct |
25 | Correct | 8 ms | 5412 KB | Output is correct |
26 | Correct | 15 ms | 5412 KB | Output is correct |
27 | Correct | 11 ms | 5412 KB | Output is correct |
28 | Correct | 7 ms | 5412 KB | Output is correct |
29 | Correct | 9 ms | 5412 KB | Output is correct |
30 | Correct | 7 ms | 5412 KB | Output is correct |
31 | Correct | 10 ms | 5416 KB | Output is correct |
32 | Correct | 7 ms | 5420 KB | Output is correct |
33 | Correct | 10 ms | 5420 KB | Output is correct |
34 | Correct | 11 ms | 5420 KB | Output is correct |
35 | Correct | 19 ms | 5484 KB | Output is correct |
36 | Correct | 7 ms | 5484 KB | Output is correct |
37 | Correct | 14 ms | 5484 KB | Output is correct |
38 | Correct | 16 ms | 5612 KB | Output is correct |
39 | Correct | 19 ms | 5740 KB | Output is correct |
40 | Correct | 16 ms | 5740 KB | Output is correct |
41 | Correct | 18 ms | 5740 KB | Output is correct |
42 | Correct | 65 ms | 5740 KB | Output is correct |
43 | Correct | 72 ms | 5740 KB | Output is correct |
44 | Correct | 73 ms | 5740 KB | Output is correct |
45 | Correct | 16 ms | 5740 KB | Output is correct |
46 | Correct | 17 ms | 5740 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 5740 KB | Output is correct |
2 | Correct | 5 ms | 5740 KB | Output is correct |
3 | Correct | 6 ms | 5740 KB | Output is correct |
4 | Correct | 6 ms | 5740 KB | Output is correct |
5 | Correct | 5 ms | 5740 KB | Output is correct |
6 | Correct | 5 ms | 5740 KB | Output is correct |
7 | Correct | 5 ms | 5740 KB | Output is correct |
8 | Correct | 5 ms | 5740 KB | Output is correct |
9 | Correct | 5 ms | 5740 KB | Output is correct |
10 | Correct | 5 ms | 5740 KB | Output is correct |
11 | Correct | 6 ms | 5740 KB | Output is correct |
12 | Correct | 6 ms | 5740 KB | Output is correct |
13 | Correct | 5 ms | 5740 KB | Output is correct |
14 | Correct | 7 ms | 5740 KB | Output is correct |
15 | Correct | 6 ms | 5740 KB | Output is correct |
16 | Correct | 6 ms | 5740 KB | Output is correct |
17 | Correct | 6 ms | 5740 KB | Output is correct |
18 | Correct | 6 ms | 5740 KB | Output is correct |
19 | Correct | 5 ms | 5740 KB | Output is correct |
20 | Correct | 11 ms | 5740 KB | Output is correct |
21 | Correct | 6 ms | 5740 KB | Output is correct |
22 | Correct | 5 ms | 5740 KB | Output is correct |
23 | Correct | 6 ms | 5740 KB | Output is correct |
24 | Correct | 7 ms | 5740 KB | Output is correct |
25 | Correct | 7 ms | 5740 KB | Output is correct |
26 | Correct | 10 ms | 5740 KB | Output is correct |
27 | Correct | 10 ms | 5740 KB | Output is correct |
28 | Correct | 6 ms | 5740 KB | Output is correct |
29 | Correct | 9 ms | 5740 KB | Output is correct |
30 | Correct | 8 ms | 5740 KB | Output is correct |
31 | Correct | 7 ms | 5740 KB | Output is correct |
32 | Correct | 6 ms | 5740 KB | Output is correct |
33 | Correct | 11 ms | 5740 KB | Output is correct |
34 | Correct | 10 ms | 5740 KB | Output is correct |
35 | Correct | 16 ms | 5740 KB | Output is correct |
36 | Correct | 10 ms | 5740 KB | Output is correct |
37 | Correct | 16 ms | 5740 KB | Output is correct |
38 | Correct | 17 ms | 5740 KB | Output is correct |
39 | Correct | 24 ms | 5740 KB | Output is correct |
40 | Correct | 16 ms | 5740 KB | Output is correct |
41 | Correct | 16 ms | 5740 KB | Output is correct |
42 | Correct | 69 ms | 5740 KB | Output is correct |
43 | Correct | 69 ms | 5740 KB | Output is correct |
44 | Correct | 77 ms | 5740 KB | Output is correct |
45 | Correct | 17 ms | 5740 KB | Output is correct |
46 | Correct | 16 ms | 5740 KB | Output is correct |
47 | Correct | 42 ms | 6252 KB | Output is correct |
48 | Correct | 14 ms | 6252 KB | Output is correct |
49 | Correct | 14 ms | 6252 KB | Output is correct |
50 | Correct | 11 ms | 6252 KB | Output is correct |
51 | Correct | 82 ms | 7404 KB | Output is correct |
52 | Correct | 68 ms | 7404 KB | Output is correct |
53 | Correct | 30 ms | 7404 KB | Output is correct |
54 | Correct | 10 ms | 7404 KB | Output is correct |
55 | Correct | 11 ms | 7404 KB | Output is correct |
56 | Correct | 917 ms | 7784 KB | Output is correct |
57 | Correct | 130 ms | 7784 KB | Output is correct |
58 | Correct | 897 ms | 7784 KB | Output is correct |
59 | Correct | 866 ms | 7784 KB | Output is correct |
60 | Correct | 910 ms | 7784 KB | Output is correct |
61 | Correct | 777 ms | 7784 KB | Output is correct |
62 | Correct | 21 ms | 7784 KB | Output is correct |
63 | Correct | 102 ms | 7784 KB | Output is correct |
64 | Correct | 103 ms | 7784 KB | Output is correct |
65 | Correct | 115 ms | 7784 KB | Output is correct |
66 | Correct | 165 ms | 7784 KB | Output is correct |
67 | Correct | 163 ms | 7784 KB | Output is correct |