You Shall Pass
Time limit1sMemory limit1024 MB
Split students into two classes to maximize expected passers, where same-class study groups raise pass probabilities by a_ij, capped at 1.
- Level
Medium7 of 10
- Topics
- Graph
- Solved
- No attempts yet
문제
Students who fail COT 3100 (Introduction to Discrete Structures) have become a major concern for the UCF professors. Matt and Sean collected a large amount of data and analyzed it, and they produced some probability estimates.
Each student has two base probabilities: the probability of passing Matt's class and the probability of passing Sean's class. Each pair of students and also has a value . If students and are in the same class, they can form a study group, and then student 's probability of passing increases by . For example, if student 's initial probability is 0.4 and , then 's probability of passing with in the same class becomes .
Matt and Sean want to split the students into two classes so that the expected number of students who pass is as large as possible. Every student is in exactly one class, but one class may be empty.
Given the initial passing probabilities and the increases from study groups, find the maximum expected number of passing students over all ways to split the students into two classes. For any class split, assume that no student's passing probability is ever higher than 1 or lower than 0, even after study group effects are counted.
Input
The first line contains a positive integer , the number of semesters to check. The data for each semester starts with an integer (), the number of students who signed up for COT 3100 that semester.
The next two lines each contain decimal values. The -th value of the first line is the probability that student passes Matt's class. The -th value of the second line is the probability that student passes Sean's class.
Then lines follow. The -th line contains non-negative decimal numbers, and the -th number on that line is .
Every decimal value in the input is written with exactly two decimal places, in the form #.##.
Output
For each semester, print the maximum expected number of passing students on its own line. Round the answer to two decimal places (for example, 1.234 rounds to 1.23 and 1.235 rounds to 1.24).