This page is still under construction.

Parts of this page are still being built. What you see may change.

Typing Contest

Time limit2sMemory limit512 MB

Summary
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 nn students in the class. The ii-th student has an initial typing speed sis_i and a typing noise fif_i. 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 1,2,…,k1, 2, \ldots, k form a team, the actual typing speed of student 11 is

s1⋅(1−f1f2−f1f3−…−f1fk)s_1 \cdot (1 - f_1 f_2 - f_1 f_3 - \ldots - f_1 f_k)

the actual typing speed of student 22 is

s2⋅(1−f2f1−f2f3−…−f2fk)s_2 \cdot (1 - f_2 f_1 - f_2 f_3 - \ldots - f_2 f_k)

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 TT (1≤T≤20001 \leq T \leq 2000), the number of test cases. Then TT test cases follow.

The first line of each test case contains a single integer nn (1≤n≤1001 \leq n \leq 100), the number of students.

Then nn lines follow. Each line contains two numbers sis_i and fif_i (1≤si≤10121 \leq s_i \leq 10^{12}, 0≤fi≤10 \leq f_i \leq 1), where sis_i is an integer and fif_i is a real number with exactly two decimal places.

It is guaranteed that ∑n≤2000\sum n \leq 2000.

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.

Examples1

  1. Example 1

    Input
    4
    3
    10 0.00
    11 0.00
    12 0.00
    3
    10 1.00
    11 1.00
    12 1.00
    3
    10 0.50
    11 0.50
    12 0.50
    3
    10 0.33
    11 0.21
    12 0.92
    
    Expected output
    33.000000000
    12.000000000
    17.250000000
    20.421900000