# Candies Codechef Solution

### We Are Discuss About CODECHEF SOLUTION

Candies Codechef Solution

## Candies Codechef Solution ## Problem

Chef gave you an infinite number of candies to sell. There are  customers, and the budget of the ��ℎ customer is �� rupees, where 1≤��≤�.

You have to choose a price , to sell the candies, where 1≤�≤�.
The ��ℎ customer will buy exactly ⌊���⌋ candies.
Chef informed you that, for each candy you sell, he will reward you with �� 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.
• ⌊�⌋ denotes the largest integer which is not greater than . For example, ⌊2.75⌋=2 and ⌊4⌋=4.

### Input Format

• The first line of input will contain a single integer , 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  and , the number of customers and the upper limit on budget/price.
• The second line contains  integers – �1,�2,…,��, the budget of ��ℎ person.
• The third line contains  integers – �1,�2,…,��, the bonus you get per candy, if you set the price as .

### Output Format

For each test case, output on a new line, the maximum amount of bonus you can get.

### Constraints

• 1≤�≤104
• 1≤�,�≤105
• 1≤��≤�
• 1≤��≤106
• The elements of array  are not necessarily non-decreasing.
• The sum of  and  over all test cases won’t exceed 105.

### Sample 1:

Input

Output

2
5 6
3 1 4 1 5
1 4 5 5 8 99
1 2
1
4 1

20
4


### Explanation:

Test case 1:

• If we choose �=1, the number of candies bought by each person is [⌊31⌋,⌊11⌋,⌊41⌋,⌊11⌋,⌊51⌋]. Thus, our bonus is (3+1+4+1+5)⋅1=14.
• If we choose �=2, the number of candies bought by each person is [⌊32⌋,⌊12⌋,⌊42⌋,⌊12⌋,⌊52⌋]. Thus our bonus is (1+0+2+0+2)⋅4=20.
• If we choose �=3, the number of candies bought by each person is [⌊33⌋,⌊13⌋,⌊43⌋,⌊13⌋,⌊53⌋]. Thus our bonus is (1+0+1+0+1)⋅5=15.
• If we choose �=4, the number of candies bought by each person is [⌊34⌋,⌊14⌋,⌊44⌋,⌊14⌋,⌊54⌋]. Thus our bonus is (0+0+1+0+1)⋅5=10.
• If we choose �=5, the number of candies bought by each person is [⌊35⌋,⌊15⌋,⌊45⌋,⌊15⌋,⌊55⌋]. Thus our bonus is (0+0+0+0+1)⋅8=8.
• If we choose �=6, the number of candies bought by each person is [⌊36⌋,⌊16⌋,⌊46⌋,⌊16⌋,⌊56⌋]. Thus our bonus is (0+0+0+0+0)⋅99=0.

Test case 2:

• If we choose �=1, the number of candies bought by each person is [⌊11⌋]. Thus, our bonus is 1⋅4=4.
• If we choose �=2, the number of candies bought by each person is [⌊12⌋]. Thus, our bonus is 0⋅1=0. ## SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.