Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- int main()
- {
- _test
- {
- int n;
- cin>>n;
- vector<int> a(2*n);
- for(auto &e: a) cin>>e;
- sort(a.begin(), a.end());
- cout<<a[n-1]-a[0] + a[2*n-1]-a[n]<<"\n";
- for(int i=0; i<n; i++)
- cout<<a[i]<<" "<<a[i+n]<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment