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

建议使用的浏览器:

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

6763:Total Eclipse

题目描述
There are $n$ cities and $m$ bidirectional roads in Byteland. These cities are labeled by $1,2,\dots,n$, the brightness of the $i$-th city is $b_i$.

Magician Sunset wants to play a joke on Byteland by making a total eclipse such that the brightness of every city becomes zero. Sunset can do the following operations for arbitrary number of times:

· Select an integer $k$ ($1\leq k\leq n$).

· Select $k$ distinct cities $c_1,c_2,\dots,c_k$ ($1\leq c_i\leq n$) such that they are connected with each other. In other words, for every pair of distinct selected cities $c_i$ and $c_j$ $(1\leq i<j\leq k)$, if you are at city $c_i$, you can reach city $c_j$ without visiting cities not in $\{c_1,c_2,\dots,c_k\}$.

· For every selected city $c_i$ ($1\leq i\leq k$), decrease $b_{c_i}$ by $1$.

Note that Sunset will always choose $k$ with the maximum possible value. Now Sunset is wondering what is the minimum number of operations he needs to do, please write a program to help him.
输入解释
The first line of the input contains a single integer $T$ ($1 \leq T \leq 10$), the number of test cases.

For each case, the first line of the input contains two integers $n$ and $m$ ($1 \leq n \leq 100\,000$, $1\leq m\leq 200\,000$), denoting the number of cities and the number of roads.

The second line of the input contains $n$ integers $b_1,b_2,\dots,b_n$ ($1\leq b_i\leq 10^9$), denoting the brightness of each city.

Each of the following $m$ lines contains two integers $u_i$ and $v_i$ ($1\leq u_i,v_i\leq n,u_i\neq v_i$), denoting an bidirectional road between the $u_i$-th city and the $v_i$-th city. Note that there may be multiple roads between the same pair of cities.
输出解释
For each test case, output a single line containing an integer, the minimum number of operations.
输入样例
1
3 2
3 2 3
1 2
2 3
输出样例
4
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6763

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

共提交 0

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