void solve(){
ll n;cin>>n;
ll flag =0;
vll b(n+2);
FOR(i,0,n+2){
cin>>b[i];
}
ll mx = *max_element(all(b));
sort(b.begin(),b.end());
ll sum = accumulate(all(b),0);
sum = sum-b[n+1];
ll s2 = sum-b[n];
dbg(sum);
dbg(s2);
ll x=-1;
for(ll i=0;i<n+1;i++){
if(sum-b[i]==mx){
x=i;
break;
}
}
if(x==-1){
ll s=0;
for(ll i=0;i<n;i++){
s+=b[i];
}
dbg(s);
if(s==b[n]){
flag=1;
for(ll i=0;i<n;i++){
cout<<b[i]<<" ";
}
cout<<endl;
}
}
else{
flag =1;
for(ll i=0;i<n+1;i++){
if(i!=x){
cout<<b[i]<<" ";
}
}
cout<<endl;
}
if(flag==0) cout<<-1<<endl;
}
What have you tried so far yourself?
You should try to make your code readable if you are asking for help.
Currently with no newlines, it is not.