#x1018. CF1949K Make Triangle
CF1949K Make Triangle
Make Triangle
题面翻译
题目描述
已知 个数 ,求任意一种把它们分成数量分别为 (保证其和为 )的 份的方案,满足各份中的数的和 可以构成三角形的三边(不允许三个顶点共线)。
输入格式
一行 表示数据组数;接着每组数据中:
- 第 1 行:
- 第 2 行:
$t\leq 10^5,\quad \sum n\leq 2\times 10^5, \quad n_a, n_b, n_c\geq 1,\quad x_i \leq 10^9$
输出格式
对每组数据,如果不存在方案,输出 ;否则输出一行 以及:
- 下一行:分在一组内的 个整数;
- 下一行:分在一组内的 个整数;
- 下一行:分在一组内的 个整数。
题目描述
You are given positive integers and three positive integers satisfying .
You want to split the positive integers into three groups, so that:
- The first group contains numbers, the second group contains numbers, the third group contains numbers.
- Let be the sum of the numbers in the first group, be the sum in the second group, and be the sum in the third group. Then are the sides of a triangle with positive area.
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 ( ) — the number of test cases. The descriptions of the test cases follow.
The first line of each test case contains the integers ( $ 3 \leq n \leq 200\,000, 1\leq n_a,n_b,n_c \leq 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 integers ( ).
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, print if it is possible to split the numbers into three groups satisfying all the conditions. Otherwise, print .
If such a split exists, then describe the three groups as follows.
On the next line, print integers — the numbers in the first group.
On the next line, print integers — the numbers in the second group.
On the next line, print integers — the numbers in the third group.
These integers should be a permutation of , and they should satisfy the conditions from the statement.
If there are multiple solutions, print any of them.
样例 #1
样例输入 #1
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
样例输出 #1
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 s into each group: the sum in each group would be , and there exists a triangle with positive area and sides , , .
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 into the first group, with sum , numbers and into the second group, with sum , and the remaining five s into the third group, with sum , as there exists a triangle with positive area and sides .