Logo
(追記) (追記ここまで)

33596번 - Make Triangle 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 2048 MB1188100.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:

  • The first group contains $n_a$ numbers, the second group contains $n_b$ numbers, the third group contains $n_c$ numbers.
  • Let $s_a$ be the sum of the numbers in the first group, $s_b$ be the sum in the second group, and $s_c$ be the sum in the third group. Then $s_a,ドル $s_b,ドル $s_c$ 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 $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.

제한

예제 입력 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 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ドル$.

힌트

출처

ICPC > Regionals > Europe > European Championship > The 2024 ICPC European Championship K번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /