-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrupted_array.cpp
More file actions
46 lines (44 loc) · 970 Bytes
/
Copy pathcorrupted_array.cpp
File metadata and controls
46 lines (44 loc) · 970 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
35
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>
using namespace std;
#define input(v) for (auto &i : v) cin >> i;
typedef long long ll;
int main()
{
int t;
cin>>t;
while (t--)
{
ll n;cin>>n;
vector<ll>b(n+2);
input(b);sort(b.begin(),b.end());
ll s = 0;
for(int i=0;i<n;i++) s+=b[i];
if(s==b[n])
{
for(int i=0;i<n;i++)cout<<b[i]<<" ";cout<<"\n";
}
else
{
ll x = s+b[n]-b[n+1];
bool ans=0;
ll pos=0;
for(int i=0;i<n+1;i++)
{
if(b[i]==x)
{
ans=1;
pos=i;
}
}
if(ans)
{
for(int i=0;i<n+1;i++)
{
if(i==pos) continue;
else cout<<b[i]<<" ";
}cout<<"\n";
}
else cout<<"-1\n";
}
}
}