题目描述
Chef gave you an infinite number of candies to sell. There are N customers, and the budget of the i^{th} customer is A_{i} rupees, where 1 ≤ A_{i} ≤ M.
You have to choose a price P, to sell the candies, where 1 ≤ P ≤ M.
The i^{th} customer will buy exactly $\lfloor{\frac{A_{i}}{P}} \rfloor$ candies.
Chef informed you that, for each candy you sell, he will reward you with C_{P} rupees, as a bonus. Find the maximum amount of bonus you can get.
Note:
We are not interested in the profit from selling the candies (as it goes to Chef), but only the amount of bonus. Refer the samples and their explanations for better understanding.
$\lfloor x \rfloor$ denotes the largest integer which is not greater than x. For example$, \lfloor 2.75 \rfloor = 2$ and $\lfloor 4 \rfloor = 4$.
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains two space-separated integers N and M, the number of customers and the upper limit on budget/price.
- The second line contains $N integers - A_{1}, A_{2}, \ldots, A_{N}$, the budget of i^{th} person.
- The third line contains $M integers - C_{1}, C_{2}, \ldots, C_{M}$, the bonus you get per candy, if you set the price as i.
------ Output Format ------
For each test case, output on a new line, the maximum amount of bonus you can get.
------ Constraints ------
$1 ≤ T ≤ 10^{4}$
$1 ≤ N, M ≤ 10^{5}$
$1 ≤ A_{i} ≤ M$
$1 ≤ C_{j} ≤ 10^{6}$
- The elements of array $C$ are not necessarily non-decreasing.
- The sum of $N$ and $M$ over all test cases won't exceed $10^{5}$.
----- Sample Input 1 ------
2
5 6
3 1 4 1 5
1 4 5 5 8 99
1 2
1
4 1
----- Sample Output 1 ------
20
4
----- explanation 1 ------
Test case $1$:
- If we choose $P = 1$, the number of candies bought by each person is $[\lfloor{\frac{3}{1}} \rfloor, \lfloor{\frac{1}{1}} \rfloor, \lfloor{\frac{4}{1}} \rfloor, \lfloor{\frac{1}{1}} \rfloor, \lfloor{\frac{5}{1}} \rfloor]$. Thus, our bonus is $(3 + 1 + 4 + 1 + 5) \cdot 1 = 14$.
- If we choose $P = 2$, the number of candies bought by each person is $[\lfloor{\frac{3}{2}} \rfloor, \lfloor{\frac{1}{2}} \rfloor, \lfloor{\frac{4}{2}} \rfloor, \lfloor{\frac{1}{2}} \rfloor, \lfloor{\frac{5}{2}} \rfloor]$. Thus our bonus is $(1 + 0 + 2 + 0 + 2) \cdot 4 = 20$.
- If we choose $P = 3$, the number of candies bought by each person is $[\lfloor{\frac{3}{3}} \rfloor, \lfloor{\frac{1}{3}} \rfloor, \lfloor{\frac{4}{3}} \rfloor, \lfloor{\frac{1}{3}} \rfloor, \lfloor{\frac{5}{3}} \rfloor]$. Thus our bonus is $(1 + 0 + 1 + 0 + 1) \cdot 5 = 15$.
- If we choose $P = 4$, the number of candies bought by each person is $[\lfloor{\frac{3}{4}} \rfloor, \lfloor{\frac{1}{4}} \rfloor, \lfloor{\frac{4}{4}} \rfloor, \lfloor{\frac{1}{4}} \rfloor, \lfloor{\frac{5}{4}} \rfloor]$. Thus our bonus is $(0 + 0 + 1 + 0 + 1) \cdot5 = 10$.
- If we choose $P = 5$, the number of candies bought by each person is $[\lfloor{\frac{3}{5}} \rfloor, \lfloor{\frac{1}{5}} \rfloor, \lfloor{\frac{4}{5}} \rfloor, \lfloor{\frac{1}{5}} \rfloor, \lfloor{\frac{5}{5}} \rfloor]$. Thus our bonus is $(0 + 0 + 0 + 0 + 1) \cdot 8 = 8$.
- If we choose $P = 6$, the number of candies bought by each person is $[\lfloor{\frac{3}{6}} \rfloor, \lfloor{\frac{1}{6}} \rfloor, \lfloor{\frac{4}{6}} \rfloor, \lfloor{\frac{1}{6}} \rfloor, \lfloor{\frac{5}{6}} \rfloor]$. Thus our bonus is $(0 + 0 + 0 + 0 + 0) \cdot 99 = 0$.
Thus, the answer is $20$.
Test case $2$:
- If we choose $P = 1$, the number of candies bought by each person is $[\lfloor{\frac{1}{1}} \rfloor]$. Thus, our bonus is $1 \cdot 4 = 4$.
- If we choose $P = 2$, the number of candies bought by each person is $[\lfloor{\frac{1}{2}} \rfloor]$. Thus, our bonus is $0 \cdot 1 = 0$.
Thus, the answer is $4$.
输入格式
见题面
输出格式
见题面