are given a number n and an exhibit b1,b2,… ,bn+2, acquired by the accompanying calculation:    some exhibit a1,a2,… ,a was speculated;    cluster a was composed to exhibit b, for example bi=ai (1≤i≤n);    The (n+1)- th component of the cluster b is the amount of the numbers in the exhibit a,

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter12: Review Of Calculus And Probability
Section12.5: Random Variables, Mean, Variance, And Covariance
Problem 5P
icon
Related questions
Question

Correct answer will be upvoted else downvoted. Computer science.

 

 You are given a number n and an exhibit b1,b2,… ,bn+2, acquired by the accompanying calculation: 

 

some exhibit a1,a2,… ,a was speculated; 

 

cluster a was composed to exhibit b, for example bi=ai (1≤i≤n); 

 

The (n+1)- th component of the cluster b is the amount of the numbers in the exhibit a, for example bn+1=a1+a2+… +an; 

 

The (n+2)- th component of the cluster b was thought of some number x (1≤x≤109), for example bn+2=x; The 

 

cluster b was rearranged. 

 

For instance, the cluster b=[2,3,7,12,2] it very well may be acquired in the accompanying ways: 

 

a=[2,2,3] and x=12; 

 

a=[3,2,7] and x=2. 

 

For the given cluster b, find any exhibit a that might have been speculated at first. 

 

Input 

 

The main line contains a solitary integer t (1≤t≤104). Then, at that point, t experiments follow. 

 

The primary line of each experiment contains a solitary integer n (1≤n≤2⋅105). 

 

The second column of each experiment contains n+2 integers b1,b2,… ,bn+2 (1≤bi≤109). 

 

It is ensured that the amount of n over all experiments doesn't surpass 2⋅105. 

 

Output 

 

For each experiment, output: 

 

"- 1", if the cluster b couldn't be gotten from any exhibit a; 

 

n integers a1,a2,… ,an, in any case.

 

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Inference
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole