Typing Contest
Time limit2sMemory limit512 MB
Choose a subset of students so that the total effective typing speed is maximized, where each pair's noise f_i and f_j reduces both speeds by s_i f_i f_j.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Sorting, Math
- Solved
- No attempts yet
Problem
Teacher Docriz is planning to select some students in his class for a typing contest.
There are students in the class. The -th student has an initial typing speed and a typing noise . When several students are selected to compete, their total typing speed is not the sum of their initial speeds. The noise each person makes affects the others.
If students form a team, the actual typing speed of student is
the actual typing speed of student is
and so on.
Teacher Docriz wants to form a team so that the total typing speed is as large as possible. Calculate the maximum total typing speed he can achieve.
Input
The first line contains an integer (), the number of test cases. Then test cases follow.
The first line of each test case contains a single integer (), the number of students.
Then lines follow. Each line contains two numbers and (, ), where is an integer and is a real number with exactly two decimal places.
It is guaranteed that .
Output
For each test case, output a line with a single real number: the maximum typing speed Teacher Docriz can achieve. Print exactly 9 digits after the decimal point. The answer must match the model solution exactly when printed with 9 decimal places.