# Solve More Problems! CodeChef Solution

### We Are Discuss About CODECHEF SOLUTION

Solve More Problems! CodeChef Solution

## Problem

Chef came across a new online judge that hasÂ ďż˝Â problems, and decided that he wants to solve them.

Chef takesÂ ďż˝ďż˝Â consecutive minutes to solve theÂ ďż˝-th problem, and will take a break ofÂ ďż˝ďż˝Â minutes immediately after solving it.
That is, Chef will solve a problem, then take a break. Solve another problem, then take another break, and so on.

Chef hasÂ ďż˝Â minutes of free time. If he chooses the problems and their order optimally, what is theÂ maximumÂ number of problems he can solve in this time?

Note that a problem is considered solved if Chef finishes solving it by theÂ ďż˝-th minute, even if the break time of the last problem extends past minuteÂ ďż˝. See the sample tests below for an example.

### Input Format

• The first line of input will contain a single integerÂ ďż˝, denoting 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 problems in the online judge and Chef’s free time, respectively.
• The second line of each test case containsÂ ďż˝Â space-separated integers â€” the valuesÂ ďż˝1,ďż˝2,â€¦,ďż˝ďż˝.
• The third line of each test case containsÂ ďż˝Â space-separated integers â€” the valuesÂ ďż˝1,ďż˝2,â€¦,ďż˝ďż˝.

### Output Format

For each test case, output on a new line theÂ maximumÂ number of problems that Chef can solve withinÂ ďż˝Â minutes.

### Constraints

• 1â‰¤ďż˝â‰¤2â‹…104
• 1â‰¤ďż˝â‰¤2â‹…105
• 1â‰¤ďż˝â‰¤108
• 1â‰¤ďż˝ďż˝â‰¤108
• 0â‰¤ďż˝ďż˝â‰¤108
• The sum ofÂ ďż˝Â over all test cases won’t exceedÂ 2â‹…105.

### Sample 1:

Input

Output

4
3 10
3 4 5
2 4 2
3 8
3 4 5
2 4 2
5 20
23 54 124 54 83
2 9 5 2 10
5 20
4 7 12 34 13
30 4 3 0 9

2
1
0
2


### Explanation:

Test caseÂ 1:Â Chef can solve the first problem followed by the second problem.

• 3Â minutes for the first problem
• 2Â minutes of break time after solving it, for a total ofÂ 5Â minutes
• 5Â minutes for the third problem, for a total ofÂ 10Â minutes
• There’s two minutes of break time left which goes beyondÂ 10Â minutes, but that’s ok: Chef finished solvingÂ 2Â problems withinÂ 10Â minutes.

Test caseÂ 2:Â The same times as the first sample, but withÂ ďż˝=8. Now, Chef can solve any one problem, but cannot solve a second one no matter what.

Test caseÂ 3:Â Chef can’t solve anything withinÂ 20Â minutes.

Test caseÂ 4:Â Chef can solve the third problem followed by the first problem.

## 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.