Buying Sweets CodeChef Solution | CodeChef Problem Solution 2022
There are sweets in the store. The cost of the sweet is rupees. Chef is a regular customer, so after buying the sweet, he gets a cashback of rupees.
Chef has 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 , 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 and — the number of sweets in the shop and the amount of money Chef has.
- The second line of each test case contains space-separated integers .
- The third line of each test case contains space-separated integers .
Output Format
For each query, print on a new line the maximum number of sweets Chef can buy.
Constraints
- It is guaranteed that the sum of over all test cases does not exceed
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 : Chef buys the first sweet, which costs rupees and has a cashback of rupee. He now has rupees remaining. He once again buys the first sweet, which leaves him with 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 : Chef buys the second sweet once.
Join Now for Solution:-
No comments:
Post a Comment