#P3705. [SDOI2017] 新生舞会
[SDOI2017] 新生舞会
Description
The school is holding a freshmen welcome ball. As an experienced senior, Cathy is responsible for pairing up dance partners.
There are boys and girls at the ball. Each pair consists of one boy and one girl, forming a one-to-one matching.
Cathy collected relationship information between these students, such as whether two people knew each other before, and computed .
Cathy also needs to consider how convenient it is for two people to dance together, for example whether their height and weight differences are too large, and computed , which represents the incompatibility when the -th boy dances with the -th girl.
Of course, there are many other issues to consider.
Cathy wants to first use a program to find a plan based on and , and then manually fine-tune the result.
A plan consists of pairs of partners. Suppose the joy levels of the pairs are , and the incompatibility levels are . Let . Cathy wants to maximize the value of .
Input Format
The first line contains an integer .
The next lines each contain integers. In the -th line, the -th number denotes .
The next lines each contain integers. In the -th line, the -th number denotes .
Output Format
Output a single number, the maximum value of . Round to decimal places. Your output must exactly match the standard output.
3
19 17 16
25 24 23
35 36 31
9 5 6
3 4 2
7 8 9
5.357143
Hint
Constraints:
- For of the testdata, .
- For of the testdata, .
- Additionally, for of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号