#abc226g. G - The baggage

G - The baggage

Score : 600600 points

问题描述

我们有五种不同重量的包裹:11, 22, 33, 44, 55。对于每一种ii (1i5)(1 \leq i \leq 5),有AiA_i个重量为ii的包裹。

另外,我们有五种不同力气的人:11, 22, 33, 44, 55。对于每一种ii (1i5)(1 \leq i \leq 5),有BiB_i个力气为ii的人。

每个人可以携带任意数量的包裹(可能为零),但包裹总重量必须不超过其力气值。

你将获得TT个测试用例。对于每个案例,请确定是否有可能通过适当分配包裹使人人都能携带所有包裹。也就是说,判断是否存在一种方法,将每个包裹分配给某个人,使得每个人都被分配到总重量不超过其力气值的包裹。允许有人不携带任何包裹。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

We have parcels with five different weights: 11, 22, 33, 44, 55. For each ii (1i5)(1 \leq i \leq 5), there are AiA_i parcels of weight ii.
Additionally, we have people with five different strengths: 11, 22, 33, 44, 55. For each ii (1i5)(1 \leq i \leq 5), there are BiB_i people with strength ii.
Each person can carry any number of parcels (possibly zero), but the total weight of the parcels must not exceed their strength.

You are given TT test cases. For each case, determine whether it is possible for the people to carry all parcels with the appropriate allocation of parcels. That is, determine whether it is possible to allocate each parcel to someone so that each person is allocated parcels whose total weight does not exceed their strength. It is fine to have someone who carries no parcels.

Constraints

  • 1T5×1041 \leq T \leq 5\times 10^4
  • 0Ai,Bi10160 \leq A_i,B_i \leq 10^{16}
  • 1A1+A2+A3+A4+A51 \leq A_1+A_2+A_3+A_4+A_5
  • 1B1+B2+B3+B4+B51 \leq B_1+B_2+B_3+B_4+B_5
  • All values in input are integers.

Input

Input is given from Standard Input. The first line contains the number of test cases TT:

TT

Then, TT test cases follow, each in the following format:

A1A_1 A2A_2 A3A_3 A4A_4 A5A_5

B1B_1 B2B_2 B3B_3 B4B_4 B5B_5

Output

Print TT lines. The ii-th line (1iT)(1\leq i\leq T) should contain Yes if all parcels can be carried in the ii-th test case, and No otherwise.

Sample Input 1

3
5 1 0 0 1
0 0 0 2 1
0 3 0 0 0
0 0 2 0 0
10000000000000000 0 0 0 0
0 0 0 0 2000000000000000

Sample Output 1

Yes
No
Yes

In the first test case, all parcels can be carried. Here is one way to do so:

  • The first person with strength 44 carries four parcels of weight 11.
  • The second person with strength 44 carries one parcel of weight 11 and another of weight 22.
  • The person with strength 55 carries one parcel of weight 55.

In the second test case, one of the two people with strength 33 has to carry two or more parcels of weight 22, which is impossible.

update @ 2024/3/10 09:56:22