#3451. Packing Under Range Regulations

0

Packing Under Range Regulations

Packing Under Range Regulations

题目描述

Solve the following problem for TT test cases. There are 10910^9 boxes numbered 1,2,…,1091,2,\dots,10^9 and NN balls numbered 1,2,…,N1,2,\dots,N.
Each box can contain at most one ball.
Determine whether it is possible to put all NN balls in the boxes so that the following condition will be satisfied.

For each integer ii from 11 through NN, the ball numbered ii is in a box numbered between LiL_i and RiR_i (inclusive).

输入格式

Input is given from Standard Input. The first line is in the following format: TT

Then, TT test cases follows, each of which is in the following format: NN L1L_1 R1R_1 L2L_2 R2R_2 …\dots LNL_N RNR_N

输出格式

Your output should have TT lines.
In the ii-th (1≤i≤T)(1 \le i \le T) line, print YesYes if it is possible to put all NN balls in the boxes so that the condition will be satisfied in the ii-th test case in the input, and printNoNo otherwise.
The checker is case-insensitive; it will accept both uppercase and lowercase letters.

2
3
1 2
2 3
3 3
5
1 2
2 3
3 3
1 3
999999999 1000000000
Yes
No

提示

1≤T≤2×1051 \le T \le 2 \times 10^5 1≤N≤2×1051 \le N \le 2 \times 10^5 1≤Li≤Ri≤1091 \le L_i \le R_i \le 10^9 The sum of NN across the test cases in one input is at most 2×1052 \times 10^5.This input contains two test cases.

In the 11-st test case, the following way to put the three balls would satisfy the condition, so we should print YesYes.

Put Ball 11 in Box 11. Put Ball 22 in Box 22. Put Ball 33 in Box 33.

In the 22-nd test case, there is no way to put the five balls to satisfy the condition, so we should print NoNo.

标签: AtCoder|abc214E

来源

AtCoder|abc214E