[1 and 2 are completely different problems. Consider reading both.]
Harry and Hermione are in a fight with the monsters. But Hermione is currently busy with Ron. So Harry is fighting alone.
Harry has initial health point . There are monsters. For -th monster(), it has damage health point and reward health point .
If Harry chooses to fight the -th monster ( ), his health point will decrease by .
Harry will win against a monster if and only if, his (Harry) health point is non-negative during the fight. Once Harry loses a fight, then he cannot fight any other monster.
If Harry wins against -th monster, that monster releases a potion that increases Harry’s health point by .
Harry can fight the monsters in any order.
Calculate the maximum number of fights Harry can win.
Note That: for all ( ),
The first line of the input contains a single integer — the number of test cases.
The first line of each test case contains two integers and — the number of monsters and initial health point of Harry respectively.
The second line contains integers — damage health point for each monster.
The third line contains integers — reward health point for each monster.
It is guaranteed that for all (),
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print a single integer — maximum number of fights Harry can win.
Input | Output |
---|---|
3 3 10 6 3 4 7 5 8 3 3 8 3 4 9 5 6 2 3 3 5 4 6 | 3 2 1 |
Explanation of test case 1:
Initial health point of Harry is 10.
Harry chooses to fight with the 1st monster. During the fight his health point becomes 4. So Harry win that fight. Then 1st monster release potion and Harry’s health point becomes 11.
Then Harry chooses to fight with the 2nd monster. In that fight Harry wins and his health point becomes 13.
Then Harry chooses to fight with the 3rd monster. In that fight Harry wins and his health point becomes 17.
So Harry can win all three fights.
Explanation of test case 2:
Initial health point of Harry is 3.
Harry chooses to fight the 2nd monster. Harry wins in that fight and his health point becomes 5.
Then Harry chooses to fight the 3rd monster. Harry wins in that fight and his health point becomes 7.
Then Harry chooses to fight the 1st monster. Unfortunately Harry losses that fight because Harry’s health point becomes -1 during the fight.
So Harry can win at most two fights.
Explanation of test case 3:
Initial health point of Harry is 3.
Harry chooses to fight the 1st monster. Harry wins in that fight and his health point becomes 4.
Then Harry chooses to fight the 2nd monster. Unfortunately Harry losses that fight because Harry’s health point becomes -1 during the fight.
So Harry can win at most one fight.