saint or a beast is supposed to be living, if his or its wellbeing esteem is positive (more prominent than or equivalent to 1); and he or it is supposed to be dead, if his or its wellbeing esteem is non-positive (not exactly or equivalent to 0).    To secure individuals

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter19: Probabilistic Dynamic Programming
Section19.4: Further Examples Of Probabilistic Dynamic Programming Formulations
Problem 7P
icon
Related questions
icon
Concept explainers
Question

Correct answer will be upvoted else downvoted. Computer science.

 

 saint or a beast is supposed to be living, if his or its wellbeing esteem is positive (more prominent than or equivalent to 1); and he or it is supposed to be dead, if his or its wellbeing esteem is non-positive (not exactly or equivalent to 0). 

 

To secure individuals in the country, the saint will battle with beasts until either the legend is dead or every one of the beasts are dead. 

 

In each battle, the legend can choose a subjective living beast and battle with it. Assume the I-th beast is chosen, and the wellbeing upsides of the legend and the I-th beast are x and y before the battle, separately. After the battle, the wellbeing upsides of the legend and the I-th beast become x−ai and y−A, separately. 

 

Note that the saint can battle a similar beast more than once. 

 

For the wellbeing of individuals in the nation, if it's not too much trouble, let them know whether the extraordinary legend can kill every one of the beasts (regardless of whether the incredible saint himself is dead subsequent to killing the last beast). 

 

Input 

 

Each test contains numerous experiments. The main line contains t (1≤t≤105) — the number of experiments. Depiction of the experiments follows. 

 

The main line of each experiment contains three integers A (1≤A≤106), B (1≤B≤106) and n (1≤n≤105) — the assault force of the extraordinary legend, the underlying wellbeing worth of the incredible saint, and the number of beasts. 

 

The second line of each experiment contains n integers a1,a2,… ,an (1≤ai≤106), where man-made intelligence means the assault force of the I-th beast. 

 

The third line of each experiment contains n integers b1,b2,… ,bn (1≤bi≤106), where bi signifies the underlying wellbeing worth of the I-th beast. 

 

It is ensured that the amount of n over all experiments doesn't surpass 105. 

 

Output 

 

For each experiment print the appropriate response: "YES" (without quotes) if the incredible saint can kill every one of the beasts. In any case, print "NO" (without quotes).

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Heuristic System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole