首页 > 其他 > 详细

【Codeforces Round #700 (Div. 2)】B. The Great Hero

时间:2021-02-08 16:40:02      阅读:26      评论:0      收藏:0      [点我收藏+]

The great hero guards the country where Homer lives. The hero has attack power A and initial health value B. There are n monsters in front of the hero. The i-th monster has attack power ai and initial health value bi.

The hero or a monster is said to be living, if his or its health value is positive (greater than or equal to 11); and he or it is said to be dead, if his or its health value is non-positive (less than or equal to 00).

In order to protect people in the country, the hero will fight with monsters until either the hero is dead or all the monsters are dead.

  • In each fight, the hero can select an arbitrary living monster and fight with it. Suppose the ii-th monster is selected, and the health values of the hero and the ii-th monster are xx and yy before the fight, respectively. After the fight, the health values of the hero and the ii-th monster become x?aix?ai and y?Ay?A, respectively.

Note that the hero can fight the same monster more than once.

For the safety of the people in the country, please tell them whether the great hero can kill all the monsters (even if the great hero himself is dead after killing the last monster).

Input

Each test contains multiple test cases. The first line contains tt (1t1051≤t≤105) — the number of test cases. Description of the test cases follows.

The first line of each test case contains three integers AA (1A1061≤A≤106), BB (1B1061≤B≤106) and nn (1n1051≤n≤105) — the attack power of the great hero, the initial health value of the great hero, and the number of monsters.

The second line of each test case contains nn integers a1,a2,,ana1,a2,…,an (1ai1061≤ai≤106), where aiai denotes the attack power of the ii-th monster.

The third line of each test case contains nn integers b1,b2,,bnb1,b2,…,bn (1bi1061≤bi≤106), where bibi denotes the initial health value of the ii-th monster.

It is guaranteed that the sum of nn over all test cases does not exceed 105105.

Output

For each test case print the answer: "YES" (without quotes) if the great hero can kill all the monsters. Otherwise, print "NO" (without quotes).

【Codeforces Round #700 (Div. 2)】B. The Great Hero

原文:https://www.cnblogs.com/rabbit1103/p/14388342.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!