QOJ.ac

QOJ

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

#2616. 攻击顺序

الإحصائيات

在某款游戏中,你控制着一个包含 $n$ 个随从的棋盘,随从编号从 $1$ 到 $n$。每个随从 $i$ 都有一个整数属性 $a_i$,称为其攻击力。

在即将到来的战斗前,你需要将这些随从从左到右排成一排。

随后,部分随从的攻击力会得到增强(buff)。每个随从 $i$ 的能力描述为:“战斗前,使另一个随机随从的攻击力增加 $b_i$”。形式化地说,对于每个 $i$,都会选择一个任意的随从 $j \neq i$,并将其攻击力 $a_j$ 增加 $b_i$。

注意,这些增强选择是相互独立的,且同时发生。特别地,任何随从的攻击力都可能被多次增强。

你希望在所有增强发生后,随从的攻击力从左到右呈非递增顺序。请判断是否可以找到一种排列方式,使得无论增强如何选择,随从的攻击力始终满足非递增条件。

输入格式

每个测试点包含多个测试用例。第一行包含测试用例的数量 $t$ ($1 \le t \le 1000$)。

每个测试用例的第一行包含一个整数 $n$ ($2 \le n \le 100$)。

接下来的 $n$ 行中,第 $i$ 行包含两个整数 $a_i$ 和 $b_i$ ($0 \le a_i, b_i \le 10^6$)。

输出格式

对于每个测试用例,如果存在一种排列方式使得无论增强如何选择,随从的攻击力始终呈非递增顺序,则输出 “Yes”,否则输出 “No”。

样例

样例输入 1

3
2
15 25
10 5
3
7 0
7 3
10 0
3
10 10
20 20
30 30

样例输出 1

Yes
Yes
No

说明

在第一个测试用例中,随从们互相增强。战斗中随从 1 和 2 的攻击力将始终分别为 20 和 35。你可以将随从按 2, 1 的顺序排列。

在第二个测试用例中,只有随从 2 会增强他人。一种合法的排列顺序是 3, 1, 2。如果随从 2 增强了随从 1,则从左到右的随从攻击力分别为 10, 10, 7。如果随从 2 增强了随从 3,则随从攻击力分别为 13, 7, 7。两种序列均为非递增。

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.