CF1512D.Corrupted Array
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a number n and an array b1,b2,…,bn+2 , obtained according to the following algorithm:
- some array a1,a2,…,an was guessed;
- array a was written to array b , i.e. bi=ai ( 1≤i≤n );
- The (n+1) -th element of the array b is the sum of the numbers in the array a , i.e. bn+1=a1+a2+…+an ;
- The (n+2) -th element of the array b was written some number x ( 1≤x≤109 ), i.e. bn+2=x ; The
- array b was shuffled.
For example, the array b=[2,3,7,12,2] it could be obtained in the following ways:
- a=[2,2,3] and x=12 ;
- a=[3,2,7] and x=2 .
For the given array b , find any array a that could have been guessed initially.
输入格式
The first line contains a single integer t ( 1≤t≤104 ). Then t test cases follow.
The first line of each test case contains a single integer n ( 1≤n≤2⋅105 ).
The second row of each test case contains n+2 integers b1,b2,…,bn+2 ( 1≤bi≤109 ).
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case, output:
- "-1", if the array b could not be obtained from any array a ;
- n integers a1,a2,…,an , otherwise.
If there are several arrays of a , 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