eolymp
bolt
Try our new interface for solving problems
Problems

Distance

Distance

In a large city a cellular network operator is holding a competition for subscribers to promote their new "pedestrian navigator" service. The main prize will be awarded to the first pair of subscribers to meet each other. The competition ends when any such meeting takes place. At the start of the competition all the subscribers are at their known positions, are able to see each other on their smartphones, and are moving at a constant speed of \textbf{10} km/h taking only pedestrian walks. Each subscriber is willing to win the prize and is indifferent to the others. In order to prepare for an award ceremony the cellular network operator needs to know the minimal amount of time after which the competition may come to an end. \InputFile In the first line of input integers \textbf{N}, \textbf{K}, and \textbf{L} are given - the number of subscribers in a cellular network company (\textbf{2} ≤ \textbf{N} ≤ \textbf{10^5}), the number of junctions (\textbf{1} ≤ \textbf{K} ≤ \textbf{10^5}), and the number of pedestrian walks (\textbf{1} ≤ \textbf{L} ≤ \textbf{10^5}) in the city, respectively. On the next \textbf{N} lines of input \textbf{S_i} (\textbf{1} ≤ \textbf{S_i} ≤ \textbf{K}) numbers are given - initial positions of subscribers (in the terms of transport graph junctions). The next \textbf{L} lines of input pedestrian paths are given in the form of integers \textbf{B_i}, \textbf{C_i} and \textbf{D_i} separated by spaces. Each line denotes that there is a two-way pedestrian path between junctions \textbf{B_i} and \textbf{C_i} (\textbf{1} ≤ \textbf{B_i}, \textbf{C_i} ≤ \textbf{K}, \textbf{B_i} ≠ \textbf{C_i}) with a length of \textbf{D_i} (\textbf{1} ≤ \textbf{D_i} ≤ \textbf{5000}) kilometers. \OutputFile Output the minimal possible number of minutes that may elapse from the start till the end of the contest. It is guaranteed that at least one pair of the subscribers can meet.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2 2 1
1
2
1 2 5
Output example #1
15
Source ACM ICPC 2010-2011 NEERC Moscow Subregional