#Q80. 「一本通 3.2 练习 4」新年好
「一本通 3.2 练习 4」新年好
Description
Original source: CQOI 2005
There are stations and bidirectional roads connecting some of them in Chongqing city. Every two stations are connected by at most one road. Starting from any station, you can reach any other station via one or more roads, but different paths may require different amounts of time. The time spent on a path equals the sum of the times required for all roads on that path.
Jiajia's home is at station , and he has five relatives living at stations . During the New Year, he needs to start from his home, visit each relative (in any order), and deliver holiday greetings. How should he travel to minimize the total time required?
Input Format
The first line contains and , the number of stations and roads, respectively.
The second line contains , the station numbers where the five relatives live.
The following lines each contain three integers , representing the two stations connected by a road and the time required to travel it.
Output Format
Output a single integer , the minimum total time required.
Sample 1
6 6
2 3 4 5 6
1 2 8
2 3 3
3 4 4
4 5 5
5 6 2
1 6 7
21
Data Range and Hints
For all data, $1\le n \le 50000, 1\le m \le 10^5, 1\lt a,b,c,d,e\le n, 1 \le x,y \le n, 1 \le t \le 100$.