当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7029:Median

题目描述
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}$.
输入解释
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$.
输出解释
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

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7029

最后修改于 2021-10-23T19:11:06+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/2000MS(Java/Others) 524288/524288K(Java/Others)