当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6201:transaction transaction transaction

题目描述
Kelukin is a businessman. Every day, he travels around cities to do some business. On August 17th, in memory of a great man, citizens will read a book named "the Man Who Changed China". Of course, Kelukin wouldn't miss this chance to make money, but he doesn't have this book. So he has to choose two city to buy and sell.
As we know, the price of this book was different in each city. It is $a_i$ $yuan$ in $i$$t$ city. Kelukin will take taxi, whose price is $1$$yuan$ per km and this fare cannot be ignored.
There are $n-1$ roads connecting $n$ cities. Kelukin can choose any city to start his travel. He want to know the maximum money he can get.
输入解释
The first line contains an integer $T$ ($1\leq T \leq 10$) , the number of test cases.
For each test case:
first line contains an integer $n$ ($2\leq n\leq 100000$) means the number of cities;
second line contains $n$ numbers, the $i$$th$ number means the prices in $i$$th$ city; $(1 \leq Price \leq 10000)$
then follows $n-1$ lines, each contains three numbers $x$, $y$ and $z$ which means there exists a road between $x$ and $y$, the distance is $z$$km$ $(1\leq z\leq 1000)$.
输出解释
For each test case, output a single number in a line: the maximum money he can get.
输入样例
1  
4  
10 40 15 30  
1 2 30
1 3 2
3 4 10
输出样例
8
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6201

最后修改于 2020-10-25T23:29:15+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 132768/132768K(Java/Others)