-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCorruptedArray.cpp
More file actions
56 lines (53 loc) · 1.22 KB
/
Copy pathCorruptedArray.cpp
File metadata and controls
56 lines (53 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Codeforces Problem: 1512D - Corrupted Array
// Link: https://codeforces.com/problemset/problem/1512/D
// Status: Accepted Language: C++
#include<iostream>
// #include<bits/stdc++.h>
// #include<set>
// #include<vector>
// #include<map>
#include<algorithm>
using namespace std;
#define ll long long
#define nl "\n"
#define ws " "
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
int main () {
int t;
cin>>t;
while (t--) {
int n;
cin>>n;
n += 2;
int arr[n];
ll b = 0;
for (int i = 0; i < n; i++) {
cin>>arr[i];
b += arr[i];
}
sort (arr, arr + n);
b -= arr[n - 1];
int idx = -1;
for (int i = 0; i < n - 1; i++) {
if (b - arr[i] == arr[n - 1]) {
idx = i;
break;
}
}
if (b - arr[n - 2] == arr[n - 2]) {
idx = n - 2;
}
if (idx != -1) {
for (int i = 0; i < n - 1; i++) {
if (i != idx) {
cout<<arr[i]<<ws;
}
}
cout<<nl;
} else {
cout<<-1<<nl;
}
}
return 0;
}