### 2003 Canadian Computing Competition, Stage 1

## Problem S5: Trucking Troubles

You are a salesperson selling trucks which can carry trucks which can carry trucks. Needless to say, your trucks are heavy. Also needless to say, you have to drive one of these trucks across a wide wet domain, and since it is wet, you need to drive over some bridges. In fact, on every road between two cities, there is a bridge but there is not a direct road between every pair of cities.

Each bridge can support a certain maximum weight. This maximum weight is an integer from 0 to 100,000.

You have been given a list of cities where there are customers who are eager to view one of your trucks. These cities are called destination cities. Since you must decide which truck you will drive through these cities, you will have to answer the following problem: what is the maximum weight that can be driven through these destination cities? You are to write a program to solve this problem.

### Input

The first line of input will contain three positive integers: c, r and d specifying the number of cities (in total), number of roads between cities and number of destination cities, respectively. The cities are numbered from 1 to c. There are at most 10,000 cities and at most 100,000 roads.

The next r lines contain triples x y w indicating that this road runs between city x and city y and it has a maximum weight capacity of w. The next d lines give the destination cities you must visit with your truck. There will be at least one destination city.

You can assume that you are starting in city 1 and that city 1 is not a destination city. You can visit the d destination cities in any order, but you must visit all d destination cities.

### Output

The output from your program is a single integer, the largest weight that can be driven through all d destination cities.### Sample Input

5 7 3 1 2 20 1 3 50 1 4 70 1 5 90 2 3 30 3 4 40 4 5 60 2 4 5

### Sample Output

30

All Submissions

Best Solutions

**Point Value:** 20 (partial)

**Time Limit:** 2.00s

**Memory Limit:** 16M

**Added:** Sep 27, 2008

**Problem Types:**[Show]

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

dopa0509on Aug 09, 2014 - 2:58:39 pm UTC Last Test case is strange..bbi5291on Aug 09, 2014 - 4:21:59 pm UTC Re: Last Test case is strange..dopa0509on Aug 10, 2014 - 1:14:32 am UTC Re: Last Test case is strange..xiaowuc1on Aug 09, 2014 - 5:25:49 pm UTC Re: Last Test case is strange..dopa0509on Aug 10, 2014 - 1:14:57 am UTC Re: Last Test case is strange..Alexon Aug 10, 2014 - 3:19:45 am UTC Re: Last Test case is strange..bbi5291on Aug 10, 2014 - 3:22:04 am UTC Re: Last Test case is strange..wangzilv1998on Jun 15, 2014 - 3:30:34 pm UTC Test cases 1 and 2Alexon Jun 15, 2014 - 8:06:06 pm UTC Re: Test cases 1 and 2wangzilv1998on Jun 15, 2014 - 8:14:59 pm UTC Re: Test cases 1 and 2adminon Dec 24, 2008 - 7:27:39 pm UTC Test cases updatedThe point value will revert to 20, so no one will lose points.

zzh8829on Oct 13, 2012 - 6:39:38 pm UTC Re: Test cases updatedSourSpinachon Oct 14, 2012 - 5:04:37 pm UTC Re: Re: Test cases updated