CF BUDDY
← Problems·

1763B · Incinerate

1200 · binary search, brute force, data structures

Problem: To destroy humanity, The Monster Association sent nn monsters to Earth's surface. The ii-th monster has health hih_i and power pip_i.

With his last resort attack, True Spiral Incineration Cannon, Genos can deal kk damage to all monsters alive. In other words, Genos can reduce the health of all monsters by kk (if k>0k > 0) with a single attack.

However, after every attack Genos makes, the monsters advance. With their combined efforts, they reduce Genos' attack damage by the power of the ^\daggerweakest monster ^\ddaggeralive. In other words, the minimum pip_i among all currently living monsters is subtracted from the value of kk after each attack.

^\daggerThe Weakest monster is the one with the least power.

^\ddaggerA monster is alive if its health is strictly greater than 00.

Will Genos be successful in killing all the monsters?

Input Format: The first line of the input contains a single integer tt (1t1001 \le t \le 100) — the number of test cases. The description of test cases follows.

The first line of each test case contains two integers, nn and kk (1n,k1051 \le n, k \le 10^5) — the number of monsters and Genos' initial attack damage. Then two lines follow, each containing nn integers describing the arrays hh and pp (1hi,pi1091 \le h_i, p_i \le 10^9).

It's guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output Format: For each test case, print the answer — "YES" (without quotes) if Genos could kill all monsters and "NO" otherwise.

Note: In the first example, after Genos' first attack, hh and kk will update to:

  • h:[11,0,6,2,3,0]h: [11,0,6,2,3,0]

  • k:71=6k: 7-1 = 6

  • h:[5,0,0,0,0,0]h: [5,0,0,0,0,0]

  • k:62=4k: 6-2 = 4

  • h:[1,0,0,0,0,0]h: [1,0,0,0,0,0]

  • k:42=2k: 4-2 = 2

  • h:[0,0,0,0,0,0]h: [0,0,0,0,0,0]

Sample Cases

Case 1

Input

3
6 7
18 5 13 9 10 1
2 7 2 1 2 6
3 4
5 5 5
4 4 4
3 2
2 1 3
1 1 1

Output

YES
NO
YES

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback