#P13199. [GCJ 2016 #2] Red Tape Committee
[GCJ 2016 #2] Red Tape Committee
题目描述
You are the head of the Department of Redundancy Reduction and Superfluity Shrinkage. Currently, the department cannot agree on whether there is too much "red tape" (inefficiency) in the department itself. They have asked you to form a Red Tape Committee to vote on the issue.
The department has members. For each member, you know the probability that that member will vote "Yes". If a member does not vote "Yes", they necessarily vote "No"; nobody abstains.
You must choose exactly members to be on the committee. The department rules dictate that must be an even number to allow for ties, which are seen as part of a healthy bureaucracy.
If you choose committee members to maximize the probability of a tie, what is that probability?
输入格式
The first line of the input gives the number of test cases, . test cases follow; each consists of two lines. The first line of a test case consists of two integers and , the sizes of the department and the committee. The second line of a test case consists of decimal values ; each has exactly two decimal places of precision and represents the probability that the -th department member will vote "Yes".
输出格式
For each test case, output one line containing Case #x: y
, where is the test case number (starting from 1) and is a floating-point number: the maximum possible probability of a tie. will be considered correct if it is within an absolute or relative error of of the correct answer.
3
2 2
0.50 0.50
4 2
0.00 0.00 1.00 1.00
3 2
0.75 1.00 0.50
Case #1: 0.5
Case #2: 1.0
Case #3: 0.5
提示
Sample Explanation
In sample case #1, you must use the only two available department members to form the committee. That committee will tie only if the two committee members vote differently, which will happen half the time. (Without loss of generality, choose the vote of the first. Then the probability that the second will vote the other way is .)
In sample case #2, the best strategy is to pick one of the members with "Yes" probability and one of the members with "Yes" probability . This guarantees a tie.
In sample case #3, suppose that we pick the two members with "Yes" probabilities of and . A tie will happen if the first one votes "Yes" and the second one votes "No" (probability ), or if the first one votes "No" and the second one votes "Yes" (probability ). So the total probability of a tie is . Choosing the two members with "Yes" probabilities of and would also make the tie probability , since the member will vote "Yes" and the member must vote "No". Choosing the two members with "Yes" probabilities of and would make the tie probability only , since the member will vote "Yes" and the member must vote "No". So is the best we can do.
Sample Explanation
- .
- .
- is even.
- each .
Small dataset (5 Pts, Test Set 1 - Visible)
- Time limit:
6015 seconds. - .
Large dataset (Test Set 2 - Hidden)
- Time limit:
12030 seconds. - .