Problem 3796 --Median

3796: Median

"
Time Limit $1$ 秒/Second(s) Memory Limit $128$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Mr. docriz has n different integers 1,2,⋯,n. He wants to divide these numbers into m disjoint sets so that the median of the j-th set is bj. Please help him determine whether it is possible. 

Note: For a set of size k, sort the elements in it as c1,c2,⋯,ck, the median of this set is defined as c⌊(k+1)/2⌋.
The first line contains an integer T(1≤T≤1000) - the number of test cases. Then T test cases follow.

The first line of each test case contains 2 integers n,m(1≤m≤n≤105) - 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 b1,b2,⋯,bm(1≤bi≤n). It is guaranteed that all the numbers in b are distinct.

It is guaranteed that ∑n≤2×106.
For each test case, output "YES'' if it is possible to achieve his goal, or "NO'' otherwise.
3
4 4
2 4 3 1
4 3
1 3 4
4 3
2 3 4
YES
YES
NO

推荐代码 查看3796 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛