310834: CF1896C. Matching Arrays
Description
You are given two arrays $a$ and $b$ of size $n$. The beauty of the arrays $a$ and $b$ is the number of indices $i$ such that $a_i > b_i$.
You are also given an integer $x$. Determine whether it is possible to rearrange the elements of $b$ such that the beauty of the arrays becomes $x$. If it is possible, output one valid rearrangement of $b$.
InputEach 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 two integers $n$ and $x$ ($1 \le n \le 2\cdot 10^5$, $0 \le x \le n$) — the size of arrays $a$ and $b$ and the desired beauty of the arrays.
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 2n$) — the elements of array $a$.
The third line of each test case contains $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le 2n$) — the elements of array $b$.
It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot 10^5$.
OutputFor each test case, output "NO" if it is not possible to rearrange $b$ to make the beauty of the arrays equal to $x$.
Otherwise, output "YES". Then, on the next line, output $n$ integers which represent the rearrangement of $b$.
If there are multiple solutions, you may output any of them.
You can output "YES" and "NO" in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
ExampleInput7 1 0 1 2 1 1 1 2 3 0 2 4 3 4 1 2 3 1 2 4 3 4 1 2 3 2 2 4 3 4 1 2 3 3 2 4 3 4 1 2 5 2 6 4 5 6 2 9 7 9 1 1Output
YES 2 NO NO YES 2 4 1 YES 4 1 2 NO YES 1 9 9 7 1Note
In test cases 1 and 2, the beauty of the arrays has to be $0$ since $a_1 = 1 \le 2 = b_1$.
In test cases 3, 4, 5 and 6, the only possible beauty of the arrays is $x = 1$ and $x = 2$. In particular, if $b$ is rearranged to $[2, 4, 1]$, then $a_3 = 3 > 1 = b_3$, so the beauty of the arrays is $1$. If $b$ is kept in the same order as given the input, then $a_2 = 4 > b_2 = 1$ and $a_3 = 3 > 2 = b_3$, so the beauty of the arrays is $2$.
Output
输入数据格式:第一行包含一个整数t(1 ≤ t ≤ 10^4),表示测试用例的数量。接下来每个测试用例包含三行,第一行包含两个整数n和x(1 ≤ n ≤ 2·10^5,0 ≤ x ≤ n),分别表示数组a和b的长度以及期望的“美丽值”。第二行包含n个整数a_1, a_2, ..., a_n(1 ≤ a_i ≤ 2n),表示数组a的元素。第三行包含n个整数b_1, b_2, ..., b_n(1 ≤ b_i ≤ 2n),表示数组b的元素。所有测试用例的n之和不超过2·10^5。
输出数据格式:对于每个测试用例,如果不能重新排列b使得数组的“美丽值”等于x,则输出“NO”。否则,输出“YES”,并在下一行输出n个整数,表示b的一种有效排列。如果有多种解决方案,可以输出其中任何一种。输出“YES”和“NO”时大小写不敏感。题目大意:给定两个长度为n的数组a和b,定义数组的“美丽值”为满足a_i > b_i的索引i的数量。给定一个整数x,判断是否可以通过重新排列数组b使得数组的“美丽值”变为x。如果可以,输出一种有效的b的排列方式。 输入数据格式:第一行包含一个整数t(1 ≤ t ≤ 10^4),表示测试用例的数量。接下来每个测试用例包含三行,第一行包含两个整数n和x(1 ≤ n ≤ 2·10^5,0 ≤ x ≤ n),分别表示数组a和b的长度以及期望的“美丽值”。第二行包含n个整数a_1, a_2, ..., a_n(1 ≤ a_i ≤ 2n),表示数组a的元素。第三行包含n个整数b_1, b_2, ..., b_n(1 ≤ b_i ≤ 2n),表示数组b的元素。所有测试用例的n之和不超过2·10^5。 输出数据格式:对于每个测试用例,如果不能重新排列b使得数组的“美丽值”等于x,则输出“NO”。否则,输出“YES”,并在下一行输出n个整数,表示b的一种有效排列。如果有多种解决方案,可以输出其中任何一种。输出“YES”和“NO”时大小写不敏感。