| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 2048 MB | 11 | 8 | 8 | 100.000% |
You are given $n$ positive integers $x_1, x_2, \dots , x_n$ and three positive integers $n_a,ドル $n_b,ドル $n_c$ satisfying $n_a + n_b + n_c = n$.
You want to split the n positive integers into three groups, so that:
Determine if this is possible. If this is possible, find one way to do so.
Each test contains multiple test cases. The first line contains an integer $t$ (1ドル ≤ t ≤ 100,円 000$) — the number of test cases. The descriptions of the $t$ test cases follow.
The first line of each test case contains the integers $n,ドル $n_a,ドル $n_b,ドル $n_c$ (3ドル ≤ n ≤ 200,円 000,ドル 1ドル ≤ n_a, n_b, n_c ≤ n - 2,ドル $n_a + n_b + n_c = n$) — the number of integers to split into three groups, and the desired sizes of the three groups.
The second line of each test case contains $n$ integers $x_1, x_2, \dots , x_n$ (1ドル ≤ x_i ≤ 10^9$).
It is guaranteed that the sum of $n$ over all test cases does not exceed 200ドル,円 000$.
For each test case, print YES if it is possible to split the numbers into three groups satisfying all the conditions. Otherwise, print NO.
If such a split exists, then describe the three groups as follows.
On the next line, print $n_a$ integers $a_1, a_2, \dots, a_{n_a}$ — the numbers in the first group.
On the next line, print $n_b$ integers $b_1, b_2, \dots , b_{n_b}$ — the numbers in the second group.
On the next line, print $n_c$ integers $c_1, c_2, \dots , c_{n_c}$ — the numbers in the third group.
These $n_a + n_b + n_c = n$ integers should be a permutation of $x_1, x_2, \dots , x_n,ドル and they should satisfy the conditions from the statement.
If there are multiple solutions, print any of them.
4 6 2 2 2 1 1 1 1 1 1 5 3 1 1 1 1 1 1 1 6 2 2 2 1 1 1 1 1 3 8 1 2 5 16 1 1 1 1 1 1 12
YES 1 1 1 1 1 1 NO NO YES 16 12 1 1 1 1 1 1
In the first test case, we can put two 1ドル$s into each group: the sum in each group would be 2ドル,ドル and there exists a triangle with positive area and sides 2ドル,ドル 2ドル,ドル 2ドル$.
In the second and third test cases, it can be shown that there is no such way to split numbers into groups.
In the fourth test case, we can put number 16 into the first group, with sum 16ドル,ドル numbers 12ドル$ and 1ドル$ into the second group, with sum 13ドル,ドル and the remaining five 1ドル$s into the third group, with sum 5ドル,ドル as there exists a triangle with positive area and sides 16ドル,ドル 13ドル,ドル 5ドル$.