#P9813. [CCC 2015 S4] Convex Hull
[CCC 2015 S4] Convex Hull
Problem Description
Given an undirected graph with points and edges, each edge has two weights and .
You need to find a path from to such that the sum of on the path is , and the sum of is as small as possible. You only need to output this minimum value. If no path satisfying the condition can be found, output .
Input Format
The first line contains three integers .
The next lines each contain four integers , representing an edge between and , with edge weights .
The last line contains two integers .
Output Format
If there exists a path satisfying the condition, output one line with one integer, the minimum possible sum of .
Otherwise, output one line with .
10 4 7
1 2 4 4
1 3 7 2
3 1 8 1
3 2 2 2
4 2 1 6
3 4 1 1
1 4 6 12
1 4
7
3 3 3
1 2 5 1
3 2 8 2
1 3 1 3
1 3
-1
Hint
Constraints:
For of the testdata, , .
For another of the testdata, , .
For of the testdata, , , , , , and .
Translated by ChatGPT 5