Recently, the convenience store Eleven-Seven is promoting its new product:
Dreamoon's Turning Fan.
It is cute, it is blue, it is also absolutely ...
useless.
However, this problem has nothing to do about turning fan.
It's actually about another recent fun discount policy of Eleven-Seven:
If three friends come to the store together, each buying A, B, C items,
then Eleven-Seven offers a discount where:
a only needs to pay for the minimum price of all his items.
b needs to pay for the maximum price of all his items,
c needs to pay for the median price of all his items.
So for example, if:
a buys items with price 3, 7, 6,
b buys items with price 11, 2, 1,
c buys items with price 2, 2, 3, 3
then a needs to pay $3, b needs to pay $11, c needs to pay $2.5
Now the brotherhood Kelvin, Ke2vin, Ke3vin went to the store together,
planning to buy N stuffs in total (where N = A + B + C)
They want to divide the N items and use the discount policy,
so that the total cost they pay is minimum possible.
Given A, B, C and the costs of the N items,
Help them!
First line contains a number T, denoting the number of testcases.
Each testcase consists of the three numbers A, B, C in a line. Following the line is N numbers describing the price of all the items that the brotherhood are to purchase, where N = A + B + C.
T ≦ 100
1 ≦ A, B, C
N = A + B + C ≦ 100000;
The prices are all integers no more than 10000.
Output the minimum cost that the brotherhood must pay in total.
Since the answer may be floating number, output 2 times the answer. (i.e. if the answer is x, output 2*x).
1 1 1 3 1 2 3 4 5
14
The answer is 7, thus output 7 x 2 = 14.
Migrated from old NTUJ.
kelvin
No. | Testdata Range | Score |
---|