CF1512D.Corrupted Array

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a number nn and an array b1,b2,,bn+2b_1, b_2, \ldots, b_{n+2} , obtained according to the following algorithm:

  • some array a1,a2,,ana_1, a_2, \ldots, a_n was guessed;
  • array aa was written to array bb , i.e. bi=aib_i = a_i ( 1in1 \le i \le n );
  • The (n+1)(n+1) -th element of the array bb is the sum of the numbers in the array aa , i.e. bn+1=a1+a2++anb_{n+1} = a_1+a_2+\ldots+a_n ;
  • The (n+2)(n+2) -th element of the array bb was written some number xx ( 1x1091 \le x \le 10^9 ), i.e. bn+2=xb_{n+2} = x ; The
  • array bb was shuffled.

For example, the array b=[2,3,7,12,2]b=[2, 3, 7, 12 ,2] it could be obtained in the following ways:

  • a=[2,2,3]a=[2, 2, 3] and x=12x=12 ;
  • a=[3,2,7]a=[3, 2, 7] and x=2x=2 .

For the given array bb , find any array aa that could have been guessed initially.

输入格式

The first line contains a single integer tt ( 1t1041 \le t \le 10^4 ). Then tt test cases follow.

The first line of each test case contains a single integer nn ( 1n21051 \le n \le 2 \cdot 10^5 ).

The second row of each test case contains n+2n+2 integers b1,b2,,bn+2b_1, b_2, \ldots, b_{n+2} ( 1bi1091 \le b_i \le 10^9 ).

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case, output:

  • "-1", if the array bb could not be obtained from any array aa ;
  • nn integers a1,a2,,ana_1, a_2, \ldots, a_n , otherwise.

If there are several arrays of aa , you can output any.

输入输出样例

  • 输入#1

    4
    3
    2 3 7 12 2
    4
    9 1 7 1 6 5
    5
    18 2 2 3 2 9 2
    3
    2 6 9 2 1

    输出#1

    2 3 7 
    -1
    2 2 2 3 9 
    1 2 6
首页