#include <stdio.h>
#include <stdlib.h>
#include <string.h>
long city[202][202];
double time[202][202];
/*最短路问题, 两次floyd即可,
第一次求出任意两个城市间的最短路, 第二次根据最短路求出任意
{
int tixt[202];
int n,m,i,j,k;
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
city[i][j]=21474800;//此处不知为何不能memset,贡献了N次R.E
for(i=1; i<=n; i++)
scanf("%d",&tixt[i]);
int x,y,d;
for(i=1; i<=m; i++)
{
scanf("%d%d%d",&x,&y,&d);
city[x][y]=(long)d;
city[y][x]=(long)d;
//city[i][i]=0;
}
for(k=1; k<=n; k++)
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
if(city[i][k]+city[k][j]<city[i][j])
city[i][j]=city[i][k]+city[k][j];
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
{
if(city[i][j]>tixt[i])
time[i][j]=tixt[i]*1.0/0.5+(city[i][j]-tixt[i])*1.0/0.1;
else
time[i][j]=city[i][j]*1.0/0.5;
}
for(k=1; k<=n; k++)
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
if(time[i][k]+time[k][j]<time[i][j])
time[i][j]=time[i][k]+time[k][j];
printf("%ld\n",(long)time[1][n]);
return 0;
}
#include <stdlib.h>
#include <string.h>
long city[202][202];
double time[202][202];
/*最短路问题, 两次floyd即可,
第一次求出任意两个城市间的最短路, 第二次根据最短路求出任意
两个城市相互到达所需消耗的最小时间。*/
{
int tixt[202];
int n,m,i,j,k;
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
city[i][j]=21474800;//此处不知为何不能memset,贡献了N次R.E
for(i=1; i<=n; i++)
scanf("%d",&tixt[i]);
int x,y,d;
for(i=1; i<=m; i++)
{
scanf("%d%d%d",&x,&y,&d);
city[x][y]=(long)d;
city[y][x]=(long)d;
//city[i][i]=0;
}
for(k=1; k<=n; k++)
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
if(city[i][k]+city[k][j]<city[i][j])
city[i][j]=city[i][k]+city[k][j];
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
{
if(city[i][j]>tixt[i])
time[i][j]=tixt[i]*1.0/0.5+(city[i][j]-tixt[i])*1.0/0.1;
else
time[i][j]=city[i][j]*1.0/0.5;
}
for(k=1; k<=n; k++)
for(i=1; i<=n; i++)
for(j=1; j<=n; j++)
if(time[i][k]+time[k][j]<time[i][j])
time[i][j]=time[i][k]+time[k][j];
printf("%ld\n",(long)time[1][n]);
return 0;
}