Logo
(追記) (追記ここまで)

24685번 - Attack Order 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB31111161.111%

문제

In a certain game, you control a board of $n$ minions numbered from 1ドル$ to $n$. Each minion $i$ is characterized by an integer $a_i,ドル called its attack.

For the upcoming fight, you will arrange the minions in a line from left to right.

After that, some of the minions' attacks will get buffed. The ability of each minion $i$ reads "Before the fight, increase the attack of another random minion by $b_i$". Formally, for each $i,ドル an arbitrary minion $j \ne i$ will be chosen and its attack $a_j$ will be increased by $b_i$.

Note that the buff choices are independent and happen simultaneously. In particular, the attack of any minion can get buffed multiple times.

You want the attacks of the minions to be non-increasing from left to right after all the buffs happen. Determine whether it's possible for you to arrange the minions in a way that guarantees that, regardless of buff choices.

입력

Each test contains multiple test cases. The first line contains the number of test cases $t$ (1ドル \le t \le 1000$). Description of the test cases follows.

The first line of each test case contains a single integer $n$ (2ドル \le n \le 100$).

The $i$-th of the next $n$ lines contains two integers $a_i$ and $b_i$ (0ドル \le a_i, b_i \le 10^6$).

출력

For each test case, print "Yes" if it is possible to arrange the minions in such a way that their attacks will be non-increasing regardless of buff choices, and "No" otherwise.

제한

예제 입력 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

힌트

In the first example test case, the minions buff each other. The attacks of minions 1ドル$ and 2ドル$ during the fight will always be 20ドル$ and 35ドル,ドル respectively. You can arrange the minions in order $\langle 2, 1 \rangle$.

In the second example test case, only minion 2ドル$ buffs someone else. One valid ordering is $\langle 3, 1, 2 \rangle$. If minion 2ドル$ buffs minion 1ドル,ドル the attacks of the minions, from left to right, will be $\langle 10, 10, 7 \rangle$. If minion 2ドル$ buffs minion 3ドル,ドル the attacks of the minions will be $\langle 13, 7, 7 \rangle$. Both sequences are non-increasing.

출처

Camp > Petrozavodsk Programming Camp > Winter 2022 > Day 7: ICPC Camp Day 2, Gennady Korotkevich Contest 6 A번

Contest > Open Cup > 2021/2022 Season > Stage 13: Grand Prix of Gomel A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /