#include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //using namespace atcoder; using namespace std; using ll = long long; #define all(A) A.begin(),A.end() using vll = vector; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) using Graph = vector>>; vector seen; bool C = true; vector dist; int main() { ll N, M; cin >> N >> M; seen.assign(N, false); Graph G(N); rep(i, M) { ll A, B, C; cin >> A >> B >> C; A--; B--; G[A].push_back(make_pair(B, C)); G[B].push_back(make_pair(A, C)); } vll T(N); rep(i, N)cin >> T[i]; vector dist(N, vll(N * 105, 1e18)); priority_queue>, vector>>, greater>>> Q; dist[0][T[0]] = T[0]; Q.push(make_pair(T[0],make_pair(0, T[0]))); while (!Q.empty()) { auto p = Q.top(); seen[p.second.first] = true; Q.pop(); for (auto k : G[p.second.first]) { //if (seen[k.first])continue; if (p.second.second + T[k.first] >= N * 101)continue; if (dist[k.first][p.second.second + T[k.first]] > dist[p.second.first][p.second.second] + k.second / p.second.second + T[k.first]) { dist[k.first][p.second.second + T[k.first]] = dist[p.second.first][p.second.second] + k.second / p.second.second + T[k.first]; Q.push(make_pair(dist[k.first][p.second.second + T[k.first]] ,make_pair(k.first, p.second.second + T[k.first]))); } } } ll an = 1e18; rep(t, N * 101) { an = min(an, dist[N - 1][t]); } cout << an << endl; }