fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  5.  
  6. int main(){
  7.  
  8. IOS;
  9. int t;
  10. cin >> t;
  11. while(t--){
  12.  
  13. int n;
  14. cin >> n;
  15. vector<int> b(n + 2);
  16. for(int i = 0; i <= n + 1; i++) cin >> b[i];
  17. sort(b.begin(), b.end());
  18. vector<int> ans;
  19. ll total = 0;
  20. for(int i = 0; i <= n; i++) total += b[i];
  21. unordered_set<int> mp(b.begin(), b.end());
  22. for(int i = 0; i <= n; i++){
  23. total -= b[i];
  24. if(mp.find(total) != mp.end()){
  25. for(int j = 0; j <= n; j++){
  26. if(j != i) ans.push_back(b[j]);
  27. }
  28. break;
  29. }
  30. total += b[i];
  31. }
  32. if(ans.empty()) cout << "-1";
  33. else{
  34. sort(ans.begin(), ans.end());
  35. for(int x : ans) cout << x << ' ';
  36. }
  37. cout << '\n';
  38.  
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0s 5364KB
stdin
3
4
1 2 3 4 10 10
3
1 1 1 2 2
5
1 2 3 3 3 12 13
stdout
1 2 3 4 
-1
1 2 3 3 3