Codeforces Round 1024 (Div. 2)
B
The Picky Cat
Codeforces
900
原题
← AC →
翻译中…

You are given an array of integers $a_1, a_2, \ldots, a_n$. You are allowed to do the following operation any number of times (possibly zero):

翻译中…
  • Choose an index $i$ ($1\le i\le n$). Multiply $a_i$ by $-1$ (i.e., update $a_i := -a_i$).
翻译中…

Your task is to determine whether it is possible to make the element at index $1$ become the median of the array after doing the above operation any number of times. Note that operations can be applied to index $1$ as well, meaning the median can be either the original value of $a_1$ or its negation.

翻译中…

The median of an array $b_1, b_2, \ldots, b_m$ is defined as the $\left\lceil \frac{m}{2} \right\rceil$-th$^{\text{∗}}$ smallest element of array $b$. For example, the median of the array $[3, 1, 2]$ is $2$, while the median of the array $[10, 1, 8, 3]$ is $3$.

翻译中…

It is guaranteed that the absolute value of the elements of $a$ are distinct. Formally, there are no pairs of indices $1\le i \lt j\le n$ where $|a_i| = |a_j|$.

翻译中…

$^{\text{∗}}$$\lceil x \rceil$ is the ceiling function which returns the least integer greater than or equal to $x$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($1\le n\le 10^5$) — the length of the array $a$.

翻译中…

The second line of each test case contains $n$ integers $a_1,a_2,\ldots,a_n$ ($|a_i|\le 10^6$, $|a_i|\neq |a_j|$) — the elements of the array $a$.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.

翻译中…

Output

翻译中…

For each testcase, output "YES" if it is possible to make the element at index $1$ become the median of the array, and "NO" otherwise.

翻译中…

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

翻译中…

Note

翻译中…

In the first test case, $a_1 = 2$ is already the median of the array $a = [2, 3, 1]$, so no operation is required.

翻译中…

In the second test case, we can do two operations: one on index $2$, and one on index $5$. The array becomes $[1, -2, 3, 4, -5]$, which has a median of $1$.

翻译中…

In the third test case, if you do an operation on index $1$, the array will become $[-4, 2, 0, -5]$, which has a median of $-4$.

翻译中…

In the fourth test case, it can be proven that no sequence of operations can make the median of the array become $5$ or $-5$.

翻译中…

样例

Input #1
7
3
2 3 1
5
1 2 3 4 5
4
4 2 0 -5
4
-5 0 4 3
4
-10 8 3 2
1
1
10
9 1000 -999 -13 456 -223 23 24 10 0
Output #1
YES
YES
YES
NO
NO
YES
YES
InputCopy OutputCopy
题目信息
题号
2102B
时间限制
1 s
内存限制
256 MB
标签
模拟
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。