QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100

#4295. 检查标记

الإحصائيات

Alexander Markovich 应该在五分钟后开始讲座,但此时他才刚刚进入大学!如果不是因为讲座被安排在那个到处都是废弃记号笔的巨大房间里,他本可以准时赶到。现在,Alexander Markovich 需要找到至少两支颜色不同且尚未完全耗尽的记号笔。

大学教授使用 $n$ 种不同颜色的记号笔,它们最初都堆在一起。我们已知对于颜色 $i$ 的记号笔,堆中有 $a_i$ 支已耗尽的记号笔和 $b_i$ 支完好的(仍可用于书写)记号笔。仅凭外观无法区分记号笔是已耗尽还是完好的。为了找到两支颜色不同的完好记号笔,Alexander Markovich 将重复以下步骤:

  1. 他从堆中取出两支颜色不同的记号笔;
  2. 然后他同时检查这两支记号笔是否都能用于书写;
  3. 如果两支记号笔都是完好的,Alexander Markovich 就拿走它们并开始讲座;
  4. 否则,如果至少有一支记号笔是已耗尽的,他会将这两支记号笔都扔进垃圾桶,并回到第 1 步。

Alexander Markovich 任意选择一对记号笔。是否存在一种可能,使得他永远无法找到两支颜色不同的完好记号笔,即在第 1 步的某次迭代中,堆中不再剩下两支颜色不同的记号笔?

你需要解决 $t$ 组测试用例。

输入格式

第一行包含一个整数 $t$ ($1 \le t \le 2 \cdot 10^5$),表示测试用例的数量。

每个测试用例由三行描述。第一行包含一个整数 $n$ ($2 \le n \le 2 \cdot 10^5$),表示记号笔颜色的数量。

每个测试用例的第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 10^9$),表示每种颜色已耗尽的记号笔数量。

每个测试用例的第三行包含 $n$ 个整数 $b_1, b_2, \dots, b_n$ ($0 \le b_i \le 10^9$),表示每种颜色完好的记号笔数量。

保证所有测试用例中 $n$ 的总和不超过 $2 \cdot 10^5$。

输出格式

对于每个测试用例,如果 Alexander Markovich 有可能永远找不到两支颜色不同的完好记号笔,则输出 “YES”,否则输出 “NO”。

样例

输入 1

3
3
1 2 1
2 1 1
2
1 1
2 2
4
1 1 1 1
2 1 2 1

输出 1

YES
NO
YES

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.