#include using namespace std; const int MAX = 1200; const int INF = 1000000000; int main(){ int N, M; cin >> N >> M; vector>> E(N); for (int i = 0; i < M; i++){ int A, B, C; cin >> A >> B >> C; A--; B--; E[A].push_back(make_pair(C, B)); E[B].push_back(make_pair(C, A)); } vector T(N); for (int i = 0; i < N; i++){ cin >> T[i]; } vector> d(N, vector(MAX + 1, INF)); priority_queue, vector>, greater>> pq; pq.push(make_tuple(T[0], 0, T[0])); while (!pq.empty()){ int dd = get<0>(pq.top()); int v = get<1>(pq.top()); int c = get<2>(pq.top()); pq.pop(); if (d[v][c] == INF){ d[v][c] = dd; for (auto P : E[v]){ int w = P.second; int c2 = min(c + T[w], MAX); if (d[w][c2] == INF){ pq.push(make_tuple(dd + P.first / c2 + T[w], w, c2)); } } } } int ans = INF; for (int i = 0; i <= MAX; i++){ ans = min(ans, d[N - 1][i]); } cout << ans << endl; }