Codeforces Round 840 (Div. 2) and Enigma 2022 - Cybros LNMIIT
B
Incinerate
Codeforces
1200
原题
← AC →
翻译中…

To destroy humanity, The Monster Association sent $n$ monsters to Earth's surface. The $i$-th monster has health $h_i$ and power $p_i$.

翻译中…

With his last resort attack, True Spiral Incineration Cannon, Genos can deal $k$ damage to all monsters alive. In other words, Genos can reduce the health of all monsters by $k$ (if $k \gt 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 $^\dagger$weakest monster $^\ddagger$alive. In other words, the minimum $p_i$ among all currently living monsters is subtracted from the value of $k$ after each attack.

翻译中…

$^\dagger$The Weakest monster is the one with the least power.

翻译中…

$^\ddagger$A monster is alive if its health is strictly greater than $0$.

翻译中…

Will Genos be successful in killing all the monsters?

翻译中…

Input

翻译中…

The first line of the input contains a single integer $t$ ($1 \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, $n$ and $k$ ($1 \le n, k \le 10^5$) — the number of monsters and Genos' initial attack damage. Then two lines follow, each containing $n$ integers describing the arrays $h$ and $p$ ($1 \le h_i, p_i \le 10^9$).

翻译中…

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

翻译中…

Output

翻译中…

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, $h$ and $k$ will update to:

翻译中…
  • $h: [11,0,6,2,3,0]$
  • $k: 7-1 = 6$
翻译中…

After second attack:

翻译中…
  • $h: [5,0,0,0,0,0]$
  • $k: 6-2 = 4$
翻译中…

After third attack:

翻译中…
  • $h: [1,0,0,0,0,0]$
  • $k: 4-2 = 2$
翻译中…

After fourth attack:

翻译中…
  • $h: [0,0,0,0,0,0]$
翻译中…

As Genos could kill all monsters, the answer is

翻译中…

YES

翻译中…

.

翻译中…

样例

Input #1
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 #1
YES
NO
YES
InputCopy OutputCopy
题目信息
题号
1763B
时间限制
1 s
内存限制
256 MB
标签
二分
暴力
数据结构
模拟
数学
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。