#include "iostream" #define M 100000000 using namespace std; typedef struct TableEntry{ double Dist; bool Known; }; TableEntry Table[101]; int n,m; double Good[101],Sum; double Crate[101][101]; int a,b,flag[101][101]; double c; void InitTable() { for(int i=1;i<=n;i++) { Table[i].Dist=-1; Table[i].Known=false; } } void Dijkstra() { InitTable(); Table[n].Dist=1.0; while(1) { int record=-1; double Max=-1.0; for(int i=1;i<=n;i++) { if(!Table[i].Known&&Max<Table[i].Dist) { Max=Table[i].Dist; record=i; } } if(record==-1) break; Table[record].Known=true; for(int i=1;i<=n;i++) { if(!Table[i].Known&&flag[record][i]&&Table[i].Dist<Max*Crate[record][i]) Table[i].Dist=Max*Crate[record][i]; } } for(int i=1;i<n;i++) if(Table[i].Dist!=-1) Sum+=Good[i]*Table[i].Dist; printf("%.2lf/n",Sum); } int main() { freopen("data.in","r",stdin); while(scanf("%d%d",&n,&m)!=EOF) { Sum=0.0; memset(flag,0,sizeof(flag)); for(int i=1;i<n;i++) scanf("%lf",&Good[i]); for(int i=1;i<=m;i++) { scanf("%d%d%lf",&a,&b,&c); if((Crate[b][a]<(1-c))||!flag[b][a]) { Crate[a][b]=1-c; Crate[b][a]=1-c; flag[a][b]=1; flag[b][a]=1; } } Dijkstra(); } while(1); return 0; }