#Lutece0833. How Long Do You Have to Draw
How Long Do You Have to Draw
Migrated from Lutece 833 How Long Do You Have to Draw
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There are two horizontal lines on the plane. One is , the other is (). On line , there are points from left to right, the x-coordinate of which are () respectively. And there are also points on line from left to right. The x-coordinate of the points are () respectively.
Now you can draw segments between the points on and by some segments. Each segment should exactly connect one point on with one point on .
The segments cannot cross with each other. By doing so, these segments, along with and , can form some triangles, which have positive areas and have no segments inside them.
The problem is, to get as much triangles as possible, what is the minimum sum of the length of these segments you draw?
Input
The first line has a number () , indicating the number of test cases.
For each test case, first line has two numbers and (, ), which is the position of and .
The second line has two numbers and (, ), which is the number of points on and .
The third line has numbers (), which is the -coordinate of the points on line .
The fourth line has numbers (), which is the -coordinate of the points on line .
Output
For test case , output Case #X:
first, then output one number,
rounded to , as the minimum total length of the segments you draw.
Samples
1
0 1
2 3
1 3
0 2 4
Case #1: 5.66
Resources
2013 ACM-ICPC China Chengdu Provincial Programming Contest