Submission #541096

# Submission time Handle Problem Language Result Execution time Memory
541096 2022-03-22T08:21:52 Z pokmui9909 None (JOI14_ho_t4) C++17
100 / 100
238 ms 32620 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define x first
#define y second
ll N, M, X;
ll H[100005];
vector<pair<ll, ll>> G[100005];
const ll INF = 1e15;
ll mh[100005];

int main(){
	cin.tie(0) -> sync_with_stdio(false);

	cin >> N >> M >> X;
	for(int i = 1; i <= N; i++){
		cin >> H[i];
		mh[i] = INF;
	}
	for(int i = 1; i <= M; i++){
		ll u, v, c; cin >> u >> v >> c;
		if(H[u] >= c) G[u].push_back({v, c});
		if(H[v] >= c) G[v].push_back({u, c});
	}
	priority_queue<pair<ll, ll>> PQ;
	PQ.push({X, 1});
	while(!PQ.empty()){
		ll d = PQ.top().x, u = PQ.top().y; PQ.pop();
		if(mh[u] != INF) continue;
		mh[u] = d;
		for(auto i : G[u]){
			if(mh[i.x] != INF) continue;
			PQ.push({min(d - i.y, H[i.x]), i.x});
		}
	}
	cout << (mh[N] == INF ? -1 : X + H[N] - mh[N] * 2);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2772 KB Output is correct
3 Correct 3 ms 2772 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 3 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 3 ms 2692 KB Output is correct
8 Correct 3 ms 2772 KB Output is correct
9 Correct 3 ms 2828 KB Output is correct
10 Correct 3 ms 2772 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 12 ms 2824 KB Output is correct
13 Correct 3 ms 2772 KB Output is correct
14 Correct 2 ms 2772 KB Output is correct
15 Correct 3 ms 2772 KB Output is correct
16 Correct 2 ms 2696 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 140 ms 15316 KB Output is correct
2 Correct 192 ms 32620 KB Output is correct
3 Correct 119 ms 14284 KB Output is correct
4 Correct 192 ms 25664 KB Output is correct
5 Correct 161 ms 31228 KB Output is correct
6 Correct 6 ms 2956 KB Output is correct
7 Correct 99 ms 9708 KB Output is correct
8 Correct 213 ms 22152 KB Output is correct
9 Correct 86 ms 11724 KB Output is correct
10 Correct 63 ms 8308 KB Output is correct
11 Correct 16 ms 4664 KB Output is correct
12 Correct 108 ms 16128 KB Output is correct
13 Correct 60 ms 16888 KB Output is correct
14 Correct 95 ms 10392 KB Output is correct
15 Correct 6 ms 3284 KB Output is correct
16 Correct 162 ms 27132 KB Output is correct
17 Correct 12 ms 4564 KB Output is correct
18 Correct 14 ms 5036 KB Output is correct
19 Correct 34 ms 5920 KB Output is correct
20 Correct 16 ms 5204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2772 KB Output is correct
3 Correct 3 ms 2772 KB Output is correct
4 Correct 2 ms 2688 KB Output is correct
5 Correct 3 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 3 ms 2692 KB Output is correct
8 Correct 3 ms 2772 KB Output is correct
9 Correct 3 ms 2828 KB Output is correct
10 Correct 3 ms 2772 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 12 ms 2824 KB Output is correct
13 Correct 3 ms 2772 KB Output is correct
14 Correct 2 ms 2772 KB Output is correct
15 Correct 3 ms 2772 KB Output is correct
16 Correct 2 ms 2696 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2692 KB Output is correct
21 Correct 140 ms 15316 KB Output is correct
22 Correct 192 ms 32620 KB Output is correct
23 Correct 119 ms 14284 KB Output is correct
24 Correct 192 ms 25664 KB Output is correct
25 Correct 161 ms 31228 KB Output is correct
26 Correct 6 ms 2956 KB Output is correct
27 Correct 99 ms 9708 KB Output is correct
28 Correct 213 ms 22152 KB Output is correct
29 Correct 86 ms 11724 KB Output is correct
30 Correct 63 ms 8308 KB Output is correct
31 Correct 16 ms 4664 KB Output is correct
32 Correct 108 ms 16128 KB Output is correct
33 Correct 60 ms 16888 KB Output is correct
34 Correct 95 ms 10392 KB Output is correct
35 Correct 6 ms 3284 KB Output is correct
36 Correct 162 ms 27132 KB Output is correct
37 Correct 12 ms 4564 KB Output is correct
38 Correct 14 ms 5036 KB Output is correct
39 Correct 34 ms 5920 KB Output is correct
40 Correct 16 ms 5204 KB Output is correct
41 Correct 86 ms 9228 KB Output is correct
42 Correct 28 ms 6012 KB Output is correct
43 Correct 71 ms 7920 KB Output is correct
44 Correct 79 ms 11820 KB Output is correct
45 Correct 174 ms 26556 KB Output is correct
46 Correct 14 ms 4840 KB Output is correct
47 Correct 204 ms 22128 KB Output is correct
48 Correct 220 ms 23112 KB Output is correct
49 Correct 152 ms 19520 KB Output is correct
50 Correct 234 ms 27336 KB Output is correct
51 Correct 23 ms 5744 KB Output is correct
52 Correct 137 ms 18332 KB Output is correct
53 Correct 87 ms 10100 KB Output is correct
54 Correct 99 ms 11628 KB Output is correct
55 Correct 84 ms 10416 KB Output is correct
56 Correct 238 ms 25744 KB Output is correct
57 Correct 34 ms 7852 KB Output is correct
58 Correct 4 ms 3156 KB Output is correct
59 Correct 82 ms 9588 KB Output is correct
60 Correct 32 ms 7732 KB Output is correct