#include // #include // using namespace atcoder; #define rep(i,n) for(int i=0;i inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } templateauto MAX(const T& a) { return *max_element(a.begin(),a.end()); } templateauto MIN(const T& a) { return *min_element(a.begin(),a.end()); } templateU SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); } templateU COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); } templateint LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); } templateint UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); } int GCD(int a, int b) { return b ? GCD(b, a%b) : a; } int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; } typedef long double ld; typedef unsigned long long int ull; typedef pair P; typedef vector vi; typedef vector vc; typedef vector vb; typedef vector vd; typedef vector vs; typedef vector vll; typedef vector> vpii; typedef vector> vpll; typedef vector vvi; typedef vector vvvi; typedef vector vvc; typedef vector vvs; typedef vector vvll; typedef map mii; typedef set si; //--------------------------------------------------------------------------------------------------- int main(void){ // Your code here! // Your code here! int n,m; cin >> n >> m; vi a(m),b(m),c(m); rep(i,m) { cin >> a[i] >> b[i] >> c[i]; a[i]--; b[i]--; } vi t(n); rep(i,n) cin >> t[i]; vector> Graph(n); rep(i,m) { Graph[a[i]].push_back({b[i],c[i]}); Graph[b[i]].push_back({a[i],c[i]}); } priority_queue, greater

> que; vi d(n,INF); d[0] = 0; que.push({0,0}); // first はcost、second はnode while(!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if (d[v] < p.first) continue; rep(i,Graph[v].size()) { P e = Graph[v][i]; if (d[e.first] > d[v] + t[v] + e.second/(p.first+t[v])) { d[e.first] = d[v] + t[v] + e.second/(p.first+t[v]); que.push({e.first,d[e.first]}); } } } cout << d[n-1] << endl; }