Delivering Goods
Time limit5sMemory limit512 MB
Given a directed weighted graph and a set of client junctions, find the minimum number of trucks so each client is reached at its shortest-path time.
- Level
Medium7 of 10
- Topics
- Graph, Shortest path, Dynamic programming, Minimum spanning tree
- Solved
- No attempts yet
Problem
You run a delivery company and have to send out trucks to bring goods to your clients. At the start of the day every package and every truck sits at your warehouse.
The road network consists of one-way streets between junctions. The warehouse and the clients are all at junctions, and you know the driving time of each street.
Your company guarantees extremely fast shipping. The trucks start driving the moment the day begins, and client receives the package at time , where is the shortest possible driving time from the warehouse to the junction of client .
What is the minimum number of trucks you have to deploy to keep that guarantee? That is, find the smallest number of trucks for which you can assign each truck a driving route so that every client is visited by some truck at time . Loading a truck at the warehouse takes no time, and dropping goods off at a client takes no time once the truck arrives. The goods are small enough that a single truck can carry packages for as many clients as necessary.
Input
The input consists of a single test case.
The first line contains three integers , , and . Here is the number of junctions in the road network (), is the number of streets (), and is the number of clients (, ).
The junctions are numbered to , and the warehouse is always at junction . The second line contains distinct integers, the junctions where the clients reside. Each of them is between and .
Each of the next lines contains integers , , (, , ). This means there is a one-way street from to with driving time .
There is at most one street from a junction to another junction , but a street from to and a street from to may both exist. Every client is reachable from the warehouse.
Output
Print a single integer, the minimum number of trucks required so that every client is visited at time by some truck.
Hint
In the first example one truck can follow the path and the other can follow . In the second example the only solution uses the three paths , , and . In the last example one truck follows , another follows , and the last one follows .