//g++ 2.cpp -std=c++14 -I . #include using namespace std; #include using namespace atcoder; using ll = long long; using ld = long double; using vi = vector; using vvi = vector; using vll = vector; using vvll = vector; using vld = vector; using vvld = vector; #define fi first #define se second #define pb push_back #define all(a) a.begin(),a.end() #define rep(i,start,end) for(ll i=start;i<(ll)(end);i++) #define per(i,start,end) for(ll i=start;i>=(ll)(end);i--) vvi dp(110,vi(12000,1e9)); using T = tuple; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,m; cin>>n>>m; vector>> g(n); rep(i,0,m){ int a,b,c; cin>>a>>b>>c; a--;b--; g[a].pb({b,c}); g[b].pb({a,c}); } vi t(n); rep(i,0,n){ cin>>t[i]; } dp[0][0]=0; priority_queue,greater> que; que.push({0,0,0}); while(!que.empty()){ auto[now,now2,time]=que.top(); que.pop(); if(time>dp[now][now2]||time>10000)continue; for(auto[next,len]:g[now]){ if(dp[next][now2+t[now]]>time+t[now]+len/(now2+t[now])){ dp[next][now2+t[now]]=time+t[now]+len/(now2+t[now]); que.push({next,now2+t[now],dp[next][now2+t[now]]}); } } } int ans=1e9; rep(i,0,11000){ ans=min(ans,dp[n-1][i]); } cout<