#C768. Fridge Shelf Weight Checker

    ID: 51577 Type: Default 1000ms 256MiB

Fridge Shelf Weight Checker

Fridge Shelf Weight Checker

You are given several test cases. In each test case, there are m shelves. For each shelf, you are provided with a weight limit and an item weight. Your task is to determine whether the item can be placed on its respective shelf without exceeding the weight limit.

More formally, for each shelf i (where i ranges from 1 to m), you need to verify that

[ w_i \leq L_i ]

where ( L_i ) is the weight limit of the shelf and ( w_i ) is the weight of the item. If the condition holds for all shelves in a test case, print YES; otherwise, print NO.

Input and output are handled via standard input and output respectively.

inputFormat

The first line of the input contains an integer T (the number of test cases). Each test case is described as follows:

  • The first line of each test case contains a single integer m — the number of shelves.
  • The second line contains m space-separated integers representing the weight limits of the shelves.
  • The third line contains m space-separated integers representing the weights of the items.

For example:

2
3
10 20 30
5 10 15
4
15 25 10 20
5 15 10 25

outputFormat

For each test case, output a single line containing either YES if all items can be placed on the shelves without exceeding their respective weight limits, or NO otherwise.

For the sample input provided, the correct output is:

YES
NO
## sample
2
3
10 20 30
5 10 15
4
15 25 10 20
5 15 10 25
YES

NO

</p>