#K73482. Goods Distribution in Compartments

    ID: 33985 Type: Default 1000ms 256MiB

Goods Distribution in Compartments

Goods Distribution in Compartments

You are given several test cases. For each test case, you need to determine whether it is possible to distribute a given number of goods into multiple compartments without exceeding the capacity of any compartment.

Each test case provides two integers: N (the number of compartments) and G (the total number of goods to distribute). On the next two lines, you are given N integers each, where the first list represents the maximum capacities of the compartments and the second list represents the current quantity of goods already in each compartment.

You need to check if the total remaining capacity, calculated by the formula $$remaining = \sum_{i=1}^{N}(max_i - current_i)$$ is at least G. If it is, output YES; otherwise, output NO.

inputFormat

The first line of input contains an integer T representing the number of test cases.

For each test case, the input is as follows:

  • The first line contains two integers N and G, where N is the number of compartments and G is the number of goods to distribute.
  • The second line contains N space-separated integers representing the maximum capacities of the compartments.
  • The third line contains N space-separated integers representing the current quantities of goods in the compartments.

outputFormat

For each test case, output a single line containing either YES if it is possible to distribute all the goods without exceeding any compartment's capacity, or NO otherwise.

## sample
2
5 20
10 20 30 40 50
5 10 15 20 25
3 15
10 5 20
8 3 15
YES

NO

</p>