A graph n n vertices connected with m We have m weighted edges. at the top i i m p i p i…
- User
A graph n n vertices connected with m We have m weighted edges. at the top i i m p i p i people live The weights of this m m edge is different.
sharpness k k other than this m m has edges whose weights have not yet been determined. He can set the weight of these ridges to any number. (even equal to the weight of one of m m initial edge)
After determining the weight of its new edges, a sharp must select an MST from the graph. If there are several modes for choosing this MST, he can choose any of the modes.
Then each person in each vertex moves to vertex 1. To cross a ridge, each person must pay the tipi as much as the weight of that ridge.
Of course, people can only use sharp selected MST edges!
Tizi wants to earn the maximum amount of money. Tell him how much this amount is if he weighs k k to determine the edge in the best way.
input In the first line of the input n n and m m and k k is given to you, which is respectively the number of graph vertices and the number of initial edges and the number of edges whose sharpness will determine their weight. in each of m m next line 3 numbers a a and b b and c c is given to you, which indicates the presence of inter-edges a a and b b by weight c c is All are guaranteed c C's are different. in each of k k next line 2 numbers a a and b You are given b which represents an intermediate edge a a and b b is that the weight of this ridge will determine the sharpness. In the last line n n number p 1 , p 2 , . . . , p n p 1 ,p 2 ,...,p n will be given to you 1 ≤ n ≤ 1 0 5 1≤n≤10 5
1 ≤ m ≤ 3 ∗ 1 0 5 1≤m≤3∗10 5
1 ≤ k ≤ 20 1≤k≤20 1 ≤ p i , c ≤ 1 0 6 1≤p i , c ≤ 10 6
output Pay the maximum amount of money you can earn in the only exit line.
Example Sample entry 1 5 5 1 3 5 2 1 2 3 2 3 5 2 4 4 4 3 6 1 3 10 20 30 40 50 Plain text Sample output 1 400 Plain text Tizi can set the mane weight between 1 and 3 to 5 and make a profit of 400. c++
- Assistant