Ankit_132

B

Nov 3rd, 2023
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7.  
  8. int main()
  9. {
  10.     _test
  11.     {
  12.         int n;
  13.         cin>>n;
  14.  
  15.         vector<int> a(2*n);
  16.         for(auto &e: a)     cin>>e;
  17.  
  18.         sort(a.begin(), a.end());
  19.  
  20.         cout<<a[n-1]-a[0] + a[2*n-1]-a[n]<<"\n";
  21.         for(int i=0; i<n; i++)
  22.             cout<<a[i]<<" "<<a[i+n]<<"\n";
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment