Make Triangle

시간 제한2초메모리 제한2048 MB

요약
n개의 양의 정수를 정해진 크기의 세 그룹으로 나눠 세 그룹 합이 넓이가 양수인 삼각형을 이루도록 만든다. 가능한 배치 하나를 출력하거나 NO를 출력한다.
난이도

보통10점 중 6점

유형
그리디, 정렬, 수학
정답자
아직 제출이 없습니다

문제

You are given nn positive integers x_1,x_2,…,x_nx\_1, x\_2, \dots , x\_n and three positive integers n_an\_a, n_bn\_b, n_cn\_c satisfying n_a+n_b+n_c=nn\_a + n\_b + n\_c = n.

You want to split the n positive integers into three groups, so that:

  • The first group contains n_an\_a numbers, the second group contains n_bn\_b numbers, the third group contains n_cn\_c numbers.
  • Let s_as\_a be the sum of the numbers in the first group, s_bs\_b be the sum in the second group, and s_cs\_c be the sum in the third group. Then s_as\_a, s_bs\_b, s_cs\_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 tt (1≤t≤100,0001 ≤ t ≤ 100\\, 000) — the number of test cases. The descriptions of the tt test cases follow.

The first line of each test case contains the integers nn, n_an\_a, n_bn\_b, n_cn\_c (3≤n≤200,0003 ≤ n ≤ 200\\, 000, 1≤n_a,n_b,n_c≤n−21 ≤ n\_a, n\_b, n\_c ≤ n - 2, n_a+n_b+n_c=nn\_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 nn integers x_1,x_2,…,x_nx\_1, x\_2, \dots , x\_n (1≤x_i≤1091 ≤ x\_i ≤ 10^9).

It is guaranteed that the sum of nn over all test cases does not exceed 200,000200\\, 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_an\_a integers a_1,a_2,…,a_n_aa\_1, a\_2, \dots, a\_{n\_a} — the numbers in the first group.

On the next line, print n_bn\_b integers b_1,b_2,…,b_n_bb\_1, b\_2, \dots , b\_{n\_b} — the numbers in the second group.

On the next line, print n_cn\_c integers c_1,c_2,…,c_n_cc\_1, c\_2, \dots , c\_{n\_c} — the numbers in the third group.

These n_a+n_b+n_c=nn\_a + n\_b + n\_c = n integers should be a permutation of x_1,x_2,…,x_nx\_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

  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
    
    예상 출력
    YES
    1 1
    1 1
    1 1
    NO
    NO
    YES
    16
    12 1
    1 1 1 1 1