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

建议使用的浏览器:

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

5834:Magic boy Bi Luo with his excited tree

题目描述
Bi Luo is a magic boy, he also has a migic tree, the tree has $N$ nodes , in each node , there is a treasure, it's value is $V[i]$, and for each edge, there is a cost $C[i]$, which means every time you pass the edge $i$ , you need to pay $C[i]$.

You may attention that every $V[i]$ can be taken only once, but for some $C[i]$ , you may cost severial times.

Now, Bi Luo define $ans[i]$ as the most value can Bi Luo gets if Bi Luo starts at node $i$.

Bi Luo is also an excited boy, now he wants to know every $ans[i]$, can you help him?
输入解释
First line is a positive integer $T( T \leq 10^4)$ , represents there are $T$ test cases.

Four each test:

The first line contain an integer $N$$( N \leq 10^5 )$.

The next line contains $N$ integers $V[i]$, which means the treasure’s value of node $i ( 1 \leq V[i] \leq 10^4 )$.

For the next $N - 1$ lines, each contains three integers $u , v , c$ , which means node $u$ and node $v$ are connected by an edge, it's cost is $c (1 \leq c \leq 10^4 )$.

You can assume that the sum of $N$ will not exceed $10^6$.
输出解释
For the i-th test case , first output Case #i: in a single line , then output $N$ lines , for the i-th line , output $ans[i]$ in a single line.
输入样例
1
5
4 1 7 7 7 
1 2 6
1 3 1
2 4 8
3 5 2
输出样例
Case #1:
15
10
14
9
15
来自杭电HDUOJ的附加信息
Author UESTC
Recommend wange2014

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

源链接: HDU-5834

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

共提交 0

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