F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Median

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 1389    Accepted Submission(s): 575


Problem Description
Mr. docriz has $n$ different integers $1, 2, \cdots, n$. He wants to divide these numbers into $m$ disjoint sets so that the median of the $j$-th set is $b_j$. Please help him determine whether it is possible.

Note: For a set of size $k$, sort the elements in it as $c_1, c_2, \cdots, c_k$, the median of this set is defined as $c_{\lfloor (k+1)/2 \rfloor}$.
 

Input
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 $2$ integers $n, m(1 \leq m \leq n \leq 10^5)$ - the number of integers that Mr. docriz has, and the number of sets he want to divide these numbers into.

The next line contains $m$ integers $b_1, b_2, \cdots, b_m(1 \leq b_i \leq n)$. It is guaranteed that all the numbers in $b$ are distinct.

It is guaranteed that $\sum n \leq 2 \times 10^6$.
 

Output
For each test case, output "YES'' if it is possible to achieve his goal, or "NO'' otherwise.
 

Sample Input
3 4 4 2 4 3 1 4 3 1 3 4 4 3 2 3 4
 

Sample Output
YES YES NO
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 13:04:27, Gzip enabled