# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240320 | 2020-06-19T09:50:12 Z | arnold518 | None (JOI14_ho_t4) | C++14 | 329 ms | 24680 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, M, X, H[MAXN+10]; vector<pii> adj[MAXN+10]; struct Queue { int v; ll w; bool operator < (const Queue &p) const { return w<p.w; } }; ll dist[MAXN+10]; bool vis[MAXN+10]; int main() { int i, j; scanf("%d%d%d", &N, &M, &X); for(i=1; i<=N; i++) scanf("%d", &H[i]); for(i=1; i<=M; i++) { int u, v, w; scanf("%d%d%d", &u, &v, &w); if(w<=H[u]) adj[u].push_back({v, w}); if(w<=H[v]) adj[v].push_back({u, w}); } priority_queue<Queue> PQ; PQ.push({1, X}); while(!PQ.empty()) { Queue now=PQ.top(); PQ.pop(); if(vis[now.v]) continue; vis[now.v]=1; dist[now.v]=now.w; for(auto nxt : adj[now.v]) { if(vis[nxt.first]) continue; PQ.push({nxt.first, min((ll)H[nxt.first], now.w-nxt.second)}); } } if(!vis[N]) printf("-1\n"); else printf("%lld\n", (ll)X+H[N]-2*dist[N]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 2688 KB | Output is correct |
2 | Correct | 8 ms | 2816 KB | Output is correct |
3 | Correct | 8 ms | 2816 KB | Output is correct |
4 | Correct | 7 ms | 2816 KB | Output is correct |
5 | Correct | 7 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 7 ms | 2688 KB | Output is correct |
8 | Correct | 8 ms | 2944 KB | Output is correct |
9 | Correct | 7 ms | 2816 KB | Output is correct |
10 | Correct | 7 ms | 2816 KB | Output is correct |
11 | Correct | 6 ms | 2688 KB | Output is correct |
12 | Correct | 7 ms | 2816 KB | Output is correct |
13 | Correct | 7 ms | 2816 KB | Output is correct |
14 | Correct | 7 ms | 2688 KB | Output is correct |
15 | Correct | 7 ms | 2816 KB | Output is correct |
16 | Correct | 6 ms | 2688 KB | Output is correct |
17 | Correct | 6 ms | 2688 KB | Output is correct |
18 | Correct | 7 ms | 2816 KB | Output is correct |
19 | Correct | 7 ms | 2688 KB | Output is correct |
20 | Correct | 7 ms | 2688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 207 ms | 13816 KB | Output is correct |
2 | Correct | 242 ms | 24680 KB | Output is correct |
3 | Correct | 133 ms | 11892 KB | Output is correct |
4 | Correct | 229 ms | 19436 KB | Output is correct |
5 | Correct | 226 ms | 23780 KB | Output is correct |
6 | Correct | 13 ms | 3072 KB | Output is correct |
7 | Correct | 131 ms | 8440 KB | Output is correct |
8 | Correct | 247 ms | 17388 KB | Output is correct |
9 | Correct | 147 ms | 10744 KB | Output is correct |
10 | Correct | 101 ms | 7288 KB | Output is correct |
11 | Correct | 24 ms | 4352 KB | Output is correct |
12 | Correct | 144 ms | 12780 KB | Output is correct |
13 | Correct | 90 ms | 13044 KB | Output is correct |
14 | Correct | 141 ms | 9720 KB | Output is correct |
15 | Correct | 11 ms | 3200 KB | Output is correct |
16 | Correct | 220 ms | 19304 KB | Output is correct |
17 | Correct | 26 ms | 4352 KB | Output is correct |
18 | Correct | 29 ms | 4608 KB | Output is correct |
19 | Correct | 59 ms | 5496 KB | Output is correct |
20 | Correct | 37 ms | 4604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 2688 KB | Output is correct |
2 | Correct | 8 ms | 2816 KB | Output is correct |
3 | Correct | 8 ms | 2816 KB | Output is correct |
4 | Correct | 7 ms | 2816 KB | Output is correct |
5 | Correct | 7 ms | 2688 KB | Output is correct |
6 | Correct | 6 ms | 2688 KB | Output is correct |
7 | Correct | 7 ms | 2688 KB | Output is correct |
8 | Correct | 8 ms | 2944 KB | Output is correct |
9 | Correct | 7 ms | 2816 KB | Output is correct |
10 | Correct | 7 ms | 2816 KB | Output is correct |
11 | Correct | 6 ms | 2688 KB | Output is correct |
12 | Correct | 7 ms | 2816 KB | Output is correct |
13 | Correct | 7 ms | 2816 KB | Output is correct |
14 | Correct | 7 ms | 2688 KB | Output is correct |
15 | Correct | 7 ms | 2816 KB | Output is correct |
16 | Correct | 6 ms | 2688 KB | Output is correct |
17 | Correct | 6 ms | 2688 KB | Output is correct |
18 | Correct | 7 ms | 2816 KB | Output is correct |
19 | Correct | 7 ms | 2688 KB | Output is correct |
20 | Correct | 7 ms | 2688 KB | Output is correct |
21 | Correct | 207 ms | 13816 KB | Output is correct |
22 | Correct | 242 ms | 24680 KB | Output is correct |
23 | Correct | 133 ms | 11892 KB | Output is correct |
24 | Correct | 229 ms | 19436 KB | Output is correct |
25 | Correct | 226 ms | 23780 KB | Output is correct |
26 | Correct | 13 ms | 3072 KB | Output is correct |
27 | Correct | 131 ms | 8440 KB | Output is correct |
28 | Correct | 247 ms | 17388 KB | Output is correct |
29 | Correct | 147 ms | 10744 KB | Output is correct |
30 | Correct | 101 ms | 7288 KB | Output is correct |
31 | Correct | 24 ms | 4352 KB | Output is correct |
32 | Correct | 144 ms | 12780 KB | Output is correct |
33 | Correct | 90 ms | 13044 KB | Output is correct |
34 | Correct | 141 ms | 9720 KB | Output is correct |
35 | Correct | 11 ms | 3200 KB | Output is correct |
36 | Correct | 220 ms | 19304 KB | Output is correct |
37 | Correct | 26 ms | 4352 KB | Output is correct |
38 | Correct | 29 ms | 4608 KB | Output is correct |
39 | Correct | 59 ms | 5496 KB | Output is correct |
40 | Correct | 37 ms | 4604 KB | Output is correct |
41 | Correct | 135 ms | 9084 KB | Output is correct |
42 | Correct | 36 ms | 5496 KB | Output is correct |
43 | Correct | 107 ms | 7708 KB | Output is correct |
44 | Correct | 97 ms | 9712 KB | Output is correct |
45 | Correct | 311 ms | 19432 KB | Output is correct |
46 | Correct | 21 ms | 3960 KB | Output is correct |
47 | Correct | 237 ms | 17264 KB | Output is correct |
48 | Correct | 329 ms | 17656 KB | Output is correct |
49 | Correct | 194 ms | 15340 KB | Output is correct |
50 | Correct | 245 ms | 20048 KB | Output is correct |
51 | Correct | 34 ms | 5112 KB | Output is correct |
52 | Correct | 191 ms | 15000 KB | Output is correct |
53 | Correct | 136 ms | 8952 KB | Output is correct |
54 | Correct | 142 ms | 10616 KB | Output is correct |
55 | Correct | 129 ms | 9568 KB | Output is correct |
56 | Correct | 266 ms | 20076 KB | Output is correct |
57 | Correct | 53 ms | 6904 KB | Output is correct |
58 | Correct | 10 ms | 3072 KB | Output is correct |
59 | Correct | 129 ms | 8696 KB | Output is correct |
60 | Correct | 53 ms | 6776 KB | Output is correct |