CF2055B.Crafting

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Crafting

As you'd expect, Florida is home to many bizarre magical forces, and Florida Man seeks to tame them.

There are nn different types of magical materials, numbered from 11 to nn. Initially, you have aia_i units of material ii for each ii from 11 to nn. You are allowed to perform the following operation:

  • Select a material ii (where 1in1\le i\le n). Then, spend 11 unit of every other material jj (in other words, jij\neq i) to gain 11 unit of material ii. More formally, after selecting material ii, update array aa as follows: ai:=ai+1a_i := a_i + 1, and aj:=aj1a_j := a_j - 1 for all jj where jij\neq i and 1jn1\le j\le n. Note that all aja_j must remain non-negative, i.e. you cannot spend resources you do not have.

You are trying to craft an artifact using these materials. To successfully craft the artifact, you must have at least bib_i units of material ii for each ii from 11 to nn. Determine if it is possible to craft the artifact by performing the operation any number of times (including zero).

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains a single integer nn (2n21052\le n\le 2\cdot 10^5) — the number of types of materials.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (0ai1090 \le a_i\le 10^9) — the amount of each material ii that you currently hold.

The third line of each test case contains nn integers b1,b2,,bnb_1, b_2, \ldots, b_n (0bi1090 \le b_i\le 10^9) — the amount of each material ii needed to produce the artifact.

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

Output

For each test case, print a single line containing either "YES" or "NO", representing whether or not the artifact can be crafted.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Note

In the first test case, perform an operation on material 11. After doing so, we will have exactly the required resources: 11 unit of material 11, and 44 units each of materials 22 and 33.

In the second test case, it can be shown that no matter how the operations are performed, it is impossible to craft the artifact.

In the third test case, we can perform the operation on material 11 twice. After these operations, we will have 33 units of material 11 and 88 units of material 22, which is more than enough to craft the artifact.

Samples

3
4
0 5 5 1
1 4 4 0
3
1 1 3
2 2 1
2
1 10
3 3
YES
NO
YES

在线编程 IDE

建议全屏模式获得最佳体验