-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1512D.cpp
More file actions
34 lines (30 loc) · 761 Bytes
/
1512D.cpp
File metadata and controls
34 lines (30 loc) · 761 Bytes
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
#include <bits/stdc++.h>
using namespace std;
void no() { cout << "-1" << endl; }
void solve() {
int n;
cin >> n;
vector<int> b(n + 2);
for (int &x : b) { cin >> x; }
multiset<int> have(b.begin(), b.end());
long long sum = accumulate(b.begin(), b.end(), 0LL);
for (int x : b) {
have.erase(have.find(x));
sum -= x;
if (sum % 2 == 0 && sum <= 2'000'000'000 && have.find(sum / 2) != have.end()) {
have.erase(have.find(sum / 2));
for (int y : have) { cout << y << " "; }
cout << endl;
return;
}
sum += x;
have.insert(x);
}
no();
}
int main() {
int tests;
cin >> tests;
while (tests-- > 0) { solve(); }
return 0;
}