QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓

#15223. Breakfast II

Estadísticas

To be a qualified university student, you not only need good grades but also need to know how to buy steamed buns and eggs.

Today, it is your turn to buy breakfast for your mentor!

This time, you need to provide your mentor with a total of $n$ steamed buns and $m$ eggs (please note that this time it might not just be 32 steamed buns and 20 eggs).

Your university can be viewed as a square on a 2D plane with coordinates ranging from $0$ to $10^4$. There are 3 canteens in the school, namely the Comprehensive Canteen, the Flavor Restaurant, and the Student Canteen. To prevent one person from buying too much breakfast, the number of steamed buns and eggs that each person can buy at each canteen cannot exceed $b$ and $e$, respectively.

There are $k$ students in total, and the $i$-th student is located at $(X_i, Y_i)$. You need to select several students to start from their respective dormitories, go to a canteen to buy breakfast, and then deliver at least $n$ steamed buns and $m$ eggs to the mentor's office. Please note that for each student, each canteen can be visited at most once.

You need to discuss and decide which students will go to buy breakfast, which canteen each student will go to, and the routes for these students, such that the sum of the lengths of all students' routes is minimized. If a student does not need to buy breakfast, they will stay in their dormitory and not go to the office. The data guarantees that a solution exists.

Input

The first line contains three space-separated integers $n, m, k$ ($1 \le n, m, k \le 10^3$), representing the required number of steamed buns, eggs, and the number of students, respectively.

The second line contains two space-separated integers $b, e$ ($1 \le b \le n, 1 \le e \le m$), representing the upper limit of steamed buns and eggs that each person can buy at each canteen.

The next 3 to 6 lines each contain two space-separated non-negative integers $x, y$ ($0 \le x, y \le 10^4$), representing the coordinates of the Comprehensive Canteen, the Flavor Restaurant, the Student Canteen, and the office, respectively.

The next $k$ lines each contain two space-separated non-negative integers $X_i, Y_i$ ($0 \le X_i, Y_i \le 10^4$), representing the coordinates of each student's dormitory.

It is guaranteed that all coordinates are distinct.

Output

A single floating-point number representing the minimum sum of route lengths. Your answer will be considered correct if the relative or absolute error does not exceed $10^{-6}$.

Examples

Input 1

32 20 2
14 15
2 2
4 8
8 4
6 2
2 8
7 7

Output 1

16.4759861592

Input 2

32 20 2
32 20
2 2
4 8
8 4
6 2
2 8
7 7

Output 2

5.9907047849

Note

For Example 1, the shortest route is shown in the figure below (where $A, B, C$ represent the three canteens, $D$ represents the office, and $S_1, S_2$ represent the locations of the students):

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.