编程介的小学生 2017-09-18 02:34 采纳率: 20.5%
浏览 804
已采纳

Transport Goods

The HERO country is attacked by other country. The intruder is attacking the capital so other cities must send supports to the capital. There are some roads between the cities and the goods must be transported along the roads.

According the length of a road and the weight of the goods, there will be some cost during transporting. The cost rate of each road is the ratio of the cost to the weight of the goods transporting on the road. It is guaranteed that the cost rate is less than 1.

On the other hand, every city must wait till all the goods arrive, and then transport the arriving goods together with its own goods to the next city. One city can only transport the goods to one city.

Your task is find the maximum weight of goods which can arrive at the capital.

Input

There are several cases.

For each case, there are two integers N (2 <= N <= 100) and M in the first line, where N is the number of cities including the capital (the capital is marked by N, and the other cities are marked from 1 to N-1), and M is the number of roads.

Then N-1 lines follow. The i-th (1 <= i <= N - 1) line contains a positive integer (<= 5000) which represents the weight of goods which the i-th city will transport to the capital.

The following M lines represent M roads. There are three numbers A, B, and C in each line which represent that there is a road between city A and city B, and the cost rate of this road is C.

Process to the end of the file.

Output

For each case, output in one line the maximum weight which can be transported to the capital, accurate up to 2 demical places.

Sample Input

5 6
10
10
10
10
1 3 0
1 4 0
2 3 0
2 4 0
3 5 0
4 5 0

Sample Output

40.00

  • 写回答

1条回答

  • threenewbee 2017-10-02 15:46
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!