#include #include #include using namespace std; using ll = long long; constexpr int iINF = 1'000'000'000; constexpr ll llINF = 1'000'000'000'000'000'000; int main () { int N, M, L, S, E; cin >> N >> M >> L >> S >> E; vector>> graph(N); for (int i = 0; i < M; i++) { int a, b, t; cin >> a >> b >> t; a--, b--; graph[a].push_back(make_pair(b, t)); graph[b].push_back(make_pair(a, t)); } vector T(L); for (int i = 0; i < L; i++) cin >> T[i]; for (int i = 0; i < L; i++) T[i]--; // トイレを中継地点として両端から探索すればよさそう。 auto cmp = [&] (pair& a, pair& b) { return b.second < a.second; }; priority_queue, vector>, decltype(cmp)> pq(cmp); vector home_to(N, llINF); pq.push(make_pair(0, 0LL)); while (!pq.empty()) { auto pos = pq.top(); pq.pop(); int u = pos.first; ll c = pos.second; if (home_to[u] < c) continue; home_to[u] = c; for (auto to : graph[u]) { int v = to.first; ll new_cost = c + to.second; if (home_to[v] <= new_cost) continue; home_to[v] = new_cost; pq.push(make_pair(v, new_cost)); } } vector school_to(N, llINF); pq.push(make_pair(N - 1, 0LL)); while (!pq.empty()) { auto pos = pq.top(); pq.pop(); int u = pos.first; ll c = pos.second; if (school_to[u] < c) continue; school_to[u] = c; for (auto to : graph[u]) { int v = to.first; ll new_cost = c + to.second; if (school_to[v] <= new_cost) continue; school_to[v] = new_cost; pq.push(make_pair(v, new_cost)); } } ll ans = llINF; for (auto i : T) { if (home_to[i] == llINF || school_to[i] == llINF) continue; if (S + E <= home_to[i]) continue; // 間に合わなかった... ans = min(ans, max(1LL * S, home_to[i]) + 1 + school_to[i]); } if (ans == llINF) { cout << -1 << "\n"; } else { cout << ans << "\n"; } }