Sales Tax
Time limit1sMemory limit512 MB
Given item prices and the dollar part of a receipt total, find the minimum and maximum sales tax values that fit the receipt.
- Level
Medium5 of 10
- Topics
- Math, Binary search, Implementation
- Solved
- No attempts yet
Problem
Albert noticed something new on a receipt while traveling in a new city. The currency there is the dollar, but the city also uses the cent (c), which is 1/100 of a dollar. So 100 cents equal 1 dollar, and no unit smaller than a cent is used. For example, a price of 4.30 means 4 dollars and 30 cents, and 5.00 can be read as 5 dollars, 500 cents, or 3 dollars and 200 cents.
The receipt lists the total paid for the items Albert bought, including sales tax. Let be the price of the -th item. Item prices exclude tax. The final payment is the sum of the item prices plus tax equal to % of that sum, where is known to be a non-negative integer. Part of the receipt is torn, so the cent digits of are not visible and only the dollar amount is known.
For example, let , , and .
- If : the item total is 10 dollars, the tax is 25% of that, or 2.50, so the total payment is 12.50.
- If : the tax is 3.00, so the total payment is 13.00.
- If : the tax is 3.90, so the total payment is 13.90.
- If : the tax is 4.00, so the total payment is 14.00.
Since here, the possible tax rate is at least 30 and less than 40.
Albert checked another receipt and found something new. As noted, no unit smaller than a cent is used, so if the tax has a fraction of a cent, each store may round it up or down to the nearest cent. The receipt does not say which rule the store used. For example, let , , and .
- The item total is 16.96.
- If : the tax is 1.696. The last digit 6 is a tenth of a cent, so the tax may be rounded down to 1.69 or up to 1.70. The total is then 18.65 or 18.66. Since , a 10% tax cannot match this receipt.
- If : the tax is 2.0352, which rounds to 2.03 or 2.04. The total is 18.99 or 19.00, so this receipt is consistent with a 12% tax.
- If : the tax is 2.8834, which rounds to 2.88 or 2.89. The total is 19.84 or 19.85, so this receipt is consistent with a 17% tax.
In this example, the dollar part of the total matches the receipt for every from 12 to 17 inclusive.
Given , , and the prices from the receipt, find the minimum and maximum tax values that match the dollar amount of .
Input
The first line contains the number of test cases .
The first line of each test case contains two integers and . The next lines contain the item prices in order. Each price always has a decimal point and exactly two digits after it for cents.
Output
For each test case, print the minimum and maximum tax values that match, separated by a space, on one line.
Constraints
- for every with
- The minimum and maximum tax values for every test case are guaranteed to be between 0 and inclusive.