CF1480B The Great Hero

题目描述

### 题意 我们定义一个人物为一个二元组$(x, y)$, 称其中 $x$ 为攻击力, $y$ 为血量. 一个英雄是一个人物. 现在有 $n$ 个怪物, 每个怪物是一个人物. 我们这样定义两个人物 $A$ 与 $B$ 交战: - $A$ 的血量减少等同于 $B$ 的攻击力的数值, $B$ 的血量也减少等同于 $A$ 的攻击力的数值. - 然后, $A$ 和 $B$ 中所有血量小于等于 $0$ 的人物死亡. 现在英雄需要消灭所有怪物, 消灭怪物的方式是与之交战. 请求出英雄能不能消灭所有的怪物, 即使英雄本人在消灭所有怪物后死亡.

输入格式

第一行包含一个正整数 $T (1\leq T \leq 10^5)$, 表示有 $T$ 组测试数据. 接下来第 $3k-2$ 行, 包括第 $k$ 组数据中, 英雄的攻击力 $A (1\leq A\leq 10^6)$, 血量 $B (1\leq B\leq 10^6)$, 怪物个数 $n(1\leq n\leq 10^5)$. 接下来第 $3k-1$ 行, 包括对于每个 $i\in[1, n]$ 第 $k$ 组数据中第 $i$ 个怪物的攻击力 $a_i (1\leq a_i\leq 10^6)$. 接下来第 $3k$ 行, 包括对于每个 $i\in[1, n]$ 第 $k$ 组数据中第 $i$ 个怪物的血量 $b_i (1\leq b_i\leq 10^6)$. 所有数据的 $n$ 的总和小于等于 $10^5$.

输出格式

对于每组测试数据, 输出仅一行一个字符串 "YES"(如果英雄能够杀死所有怪物) 或 "NO"(如果英雄不能杀死所有怪物) (不包括括号).

说明/提示

In the first example: There will be $ 6 $ fights between the hero and the only monster. After that, the monster is dead and the health value of the hero becomes $ 17 - 6 \times 2 = 5 > 0 $ . So the answer is "YES", and moreover, the hero is still living. In the second example: After all monsters are dead, the health value of the hero will become $ 709 $ , regardless of the order of all fights. So the answer is "YES". In the third example: A possible order is to fight with the $ 1 $ -st, $ 2 $ -nd, $ 3 $ -rd and $ 4 $ -th monsters. After all fights, the health value of the hero becomes $ -400 $ . Unfortunately, the hero is dead, but all monsters are also dead. So the answer is "YES". In the fourth example: The hero becomes dead but the monster is still living with health value $ 1000 - 999 = 1 $ . So the answer is "NO".