| “壹零杯”第三届西华师范大学程序设计竞赛 |
|---|
| Finished |
In a vast strategic buffer zone, there are $$$n$$$ frontline outposts, indexed from $$$1$$$ to $$$n$$$. Due to the intensity of the battle, the headquarters commands that every single outpost must receive supplies.
As the logistics commander, you have two methods to provide supplies to the outposts:
Your goal is to formulate a plan with the minimum total cost such that all $$$n$$$ outposts are supplied.
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \times 10^5$$$, $$$0 \le m \le 2 \times 10^5$$$), representing the number of outposts and the number of potential roads.
The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ denotes the cost of directly airdropping supplies to the $$$i$$$-th outpost.
The following $$$m$$$ lines each contain three integers $$$u, v, w$$$ ($$$1 \le u, v \le n$$$, $$$1 \le w \le 10^9$$$), representing a potential bidirectional road between outpost $$$u$$$ and outpost $$$v$$$ with a cost of $$$w$$$.
Note: The input may contain self-loops or multiple edges between the same pair of outposts.
Output a single integer representing the minimum total cost required to supply all outposts.
3 25 10 31 2 12 3 2
6
In the sample case, the optimal strategy is:
| Name |
|---|


