First Pair to Meet
Time limit2sMemory limit512 MB
Given people at vertices of a weighted undirected graph, find the minimum over all pairs of half their shortest-path distance; roads are traversed at 10 km/h and the time prints in minutes.
- Level
Hard8 of 10
- Topics
- Graph, Shortest path, Math, Sorting
- Solved
- No attempts yet
Problem
ACM Telecom is running an event to promote its new app, "Meeting Route". The first two people who meet through the app get a prize.
Right before the event starts, everyone knows where everyone else is from the app. Once two people decide to meet, they start at the same moment and move toward each other along the shortest route the app gives them. Everyone moves at 10 km/h. If the shortest route between two people is km long, each of them covers km and then they meet.
To prepare the award ceremony, ACM Telecom needs the smallest time the event can take. Given the positions of the people when the event starts and the map of the area, compute that time.
Input
The first line contains the number of participants , the number of vertices on the map, and the number of roads joining the vertices. (, , )
Each of the next lines contains one number , the position of a person. () It means person stands at vertex . Several people may stand at the same vertex.
Each of the next lines describes one road as , , . (, ) It means there is a road of length km between vertex and vertex . Roads can be travelled in both directions, and the same two vertices may be joined by more than one road.
Output
Print one integer, the shortest time in minutes it takes for some two people to meet. At least one pair of people can reach each other. Two people who start at the same vertex meet at once, so the answer can be 0.