#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair>; const ll INF = (1LL << 61); ll mod = 1000000007; int N, M; vector>edge[110]; int T[110]; vector> dijkstra(int s) { priority_queue, greater

>pq; // しおむすびを合計t分食べているという情報を追加 vector>dist(N, vector(1010, INF)); dist[s][T[s]] = T[s]; pq.push({ dist[s][T[s]],{s, T[s] } }); while (!pq.empty()) { P p = pq.top(); pq.pop(); ll d = p.first, from = p.second.first, t = p.second.second; if (dist[from][t] < d)continue; for (auto nv : edge[from]) { ll to = nv.first; ll cost = nv.second; cost /= t; if (to != N)cost += T[to]; if (dist[from][t] + cost < dist[to][min(1001LL, t + T[to])]) { dist[to][min(1001LL, t + T[to])] = dist[from][t] + cost; pq.push({ dist[to][min(1001LL, t + T[to])],{to, min(1001LL, t + T[to])} }); } } } return dist; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> M; for (int i = 0; i < M; i++) { int A, B, C; cin >> A >> B >> C; A--; B--; edge[A].push_back({ B,C }); edge[B].push_back({ A,C }); } for (int i = 0; i < N; i++)cin >> T[i]; auto ans = dijkstra(0); int res = INF; for (int i = 0; i < 1010; i++)res = min(res, ans[N - 1][i]); cout << res << endl; return 0; }