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

建议使用的浏览器:

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

7024:Penguin Love Tour

题目描述
Penguin loves driving. One day he found some islands, and wanted to go on a tour.

These $n$ islands are connected by $n - 1$ undirected roads, the $i$-th road connects island $u_i$, $v_i$ take $w_i$ to pass. Any two islands can reach each other. The i-th island has a power value $p_i$. You can do the following operations at most once for each island:

1. Choose a road that connects to the island

2. Change the cost of the road $w$ to $max(0,w-p)$

The penguin will choose an island arbitrarily and follow the shortest path to another island. Since the penguin likes to travel long distances, he will choose the longest path from all possible options.But you don't want to make his journey too tiring. Can you reasonably allocate the power value of each island to make the penguin's travel as short as possible?
输入解释
The first line contains an integer $T(T \le 1000)$. Then $T$ test cases follow.

For each test case the first line contains one integer $n(1\le n\le 10^5)$.

Then a line with $n$ integers, $p_1, p_2, ..., p_n$ $(0 \le p_i \le 10 ^ 5) $ the power of the islands.

Then $n - 1$ lines, each line containing three integers $u_i$, $v_i$, $w_i$ $ (1 \le u_i, v_i \le n, 1 \le w_i \le 10^5)$ describing a road.

It is guaranteed that $\sum n <4\times10^5 $.
输出解释
For each test case, print a line with an integer, representing the shortest travel length.
输入样例
1
9
3 2 1 1 2 2 4 4 3
5 3 5
4 2 1
6 4 1
2 1 1
3 2 2
9 2 4
7 5 3
8 4 4
输出样例
3

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

源链接: HDU-7024

最后修改于 2021-10-23T19:11:06+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 262144/262144K(Java/Others)