GUPTA MECHANICAL

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

Wednesday 27 April 2022

Buying Sweets CodeChef Solution | CodeChef Problem Solution 2022

There are N sweets in the store. The cost of the ith sweet is Ai rupees. Chef is a regular customer, so after buying the ith sweet, he gets a cashback of Bi 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 A1,A2,,AN.
  • The third line of each test case contains N space-separated integers B1,B2,,BN.
Solution Click Below:- 

Output Format

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

Constraints

  • 1T2105
  • 1N2105
  • 1Bi<Ai109
  • 1R109
  • It is guaranteed that the sum of N over all test cases does not exceed 2105

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 32+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.

Join Now for Solution:- 

No comments:

Post a Comment