## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## Buying Sweets CodeChef Solution | CodeChef Problem Solution 2022

There are $N$ sweets in the store. The cost of the ${i}^{th}$ sweet is ${A}_{i}$ rupees. Chef is a regular customer, so after buying the ${i}^{th}$ sweet, he gets a cashback of ${B}_{i}$ rupees.

Chef has $R$ rupees. He is fond of all the sweets, so he wants you to calculate the maximum number of sweets he can buy. Note that he can buy the same type of sweet multiple times, as long as he has the money to do so.

### Input Format

• The first line of input will contain $T$, the number of test cases.
• Each test case consists of three lines of input.
• The first line of each test case contains two space-separated integers $N$ and $R$ — the number of sweets in the shop and the amount of money Chef has.
• The second line of each test case contains $N$ space-separated integers ${A}_{1},{A}_{2},\dots ,{A}_{N}$.
• The third line of each test case contains $N$ space-separated integers ${B}_{1},{B}_{2},\dots ,{B}_{N}$.
Solution Click Below:-

### Output Format

For each query, print on a new line the maximum number of sweets Chef can buy.

### Constraints

• $1\le T\le 2\cdot {10}^{5}$
• $1\le N\le 2\cdot {10}^{5}$
• $1\le {B}_{i}<{A}_{i}\le {10}^{9}$
• $1\le R\le {10}^{9}$
• It is guaranteed that the sum of $N$ over all test cases does not exceed $2\cdot {10}^{5}$

### Sample Input 1

3
3 3
2 3 4
1 1 1
2 4
5 4
1 2
4 10
4 4 5 5
1 2 4 2


### Sample Output 1

2
1
7


### Explanation

Test case $1$: Chef buys the first sweet, which costs $2$ rupees and has a cashback of $1$ rupee. He now has $3-2+1=2$ rupees remaining. He once again buys the first sweet, which leaves him with $1$ rupee, at which point no more sweets can be bought.

Chef and Chapters CodeChef Solution | CodeChef Problem Solution 2022

Presents for Cheffina CodeChef Solution | CodeChef Problem Solution 2022

Chef and Bird farm CodeChef Solution | CodeChef Problem Solution 2022

Valentine Vex CodeChef Solution | CodeChef Problem Solution 2022

Buying Sweets CodeChef Solution | CodeChef Problem Solution 2022

Reduce to 1 CodeChef Solution | CodeChef Problem Solution 2022

Three Arrays CodeChef Solution | CodeChef Problem Solution 2022

Test case $2$: Chef buys the second sweet once.