시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 6 | 5 | 4 | 100.000% |
Mr. Docriz has $n$ different kinds of objects indexed by $1, 2, \ldots, n$. An object of the $i$-th kind weighs $i$ kilograms. For each $i$, Mr. Docriz has $b_i$ objects of the $i$-th kind. Among those objects, there are $a_i$ precious objects, and the remaining ones are common objects. Now, he wants to divide all his objects into some (one or more) disjoint sets. These sets have to satisfy the following conditions:
Please tell him whether it is possible.
For a set of size $k$, if we sort its elements by non-descending weight as $c_1, c_2, \ldots, c_k$, the median weight of this set is defined as the weight of $c_{\lfloor (k + 1) / 2 \rfloor}$.
The first line contains an integer $T$ ($1 \leq T \leq 1000$), the number of test cases. Then $T$ test cases follow.
The first line of each test case contains one integer $n$ ($1 \leq n \leq 10^6$), specifying how many different kinds of objects Mr. Docriz has.
Then $n$ lines follow. The $i$-th of these lines contains two integers $a_i$ and $b_i$ ($0 \leq a_i \leq b_i \leq 10^9$), indicating that there are $a_i$ precious objects of the $i$-th kind, and $b_i$ objects of the $i$-th kind in total.
It is guaranteed that $\sum n \leq 2 \cdot 10^6$.
For each test case, output "YES
" if it is possible to achieve the goal, or "NO
" otherwise.
3 4 1 1 1 1 1 1 1 1 4 1 1 0 1 1 1 1 1 4 0 1 1 1 1 1 1 1
YES YES NO