Tommaso has just happened to know of a massive discount campaign in a supermarket in his neighbourhood. Being notoriously greedy, he is now planning to take the most advantage out of it!
The supermarket is selling unique items, each marked with a distinct identifier from to . Every item has a full price , a discounted price , and an attached promotional code . Once a buyer has to pay for her shopping cart, she will qualify for the discounted price for a bought item if and only if she has at least one matching promotional code attached to some item(s) in her shopping cart. Otherwise, she will have to pay the full price.
Notice that if item gives a promotional code for item , and vice-versa item provides a code for item , it is possible to buy items and both at their discounted prices. On the other hand, it is impossible to buy multiple copies of the same item, and having several promotional codes for a single item does not increase the discount. It is however possible for an item to provide a promotional code for itself, so that it is never paid full price.
Tommaso is willing to buy just about anything from the supermarket, in order to boast the highest possible discount percentage. Assume that Tommaso chooses to buy a certain subset of the items, whose total full price is Ptot, for which he pays an actual price of Pdiscount using promotional codes. Then the discount percentage for those items is computed as:
Help Tommaso find the best possible bargain!
Input data
The first line contains the only integer . The following lines each contain the three integers , and for item .
Output data
You need to write a single line with a floating-point number: the best percentage of discount Tommaso can obtain.
Constraints and clarifications
- ;
- ;
- ;
- Your program will be tested against several test cases grouped in subtasks. In order to obtain the score of a subtask, your program needs to correctly solve all of its test cases. You answer is considered correct if it is within of the correct value.
# | Score | Constraints |
---|---|---|
1 | 0 | Examples |
2 | 10 | for all |
3 | 15 | |
4 | 20 | |
5 | 20 | for all |
6 | 25 | and for all |
7 | 10 | No additional limitations. |
Example 1
stdin
6
100 90 1
10 9 2
90 20 5
100 80 2
40 30 3
100 10 3
stdout
80.000000000
Explanation
In the first sample case the best solution is to buy items , and spending + + = instead of + + = . The discount percentage is This is because item ’s promotional code enables the discount of item , and the code of item enables the discount of item .
Example 2
stdin
5
100 70 1
10 3 2
11 3 3
12 3 1
10 9 4
stdout
72.727272727
Explanation
In the second sample case the best solution is to buy items , and spending + + = instead of + + = . The discount percentage is . The three items enable the discount for each other, therefore all of them are paid with the sale price.