Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- int n;
- cin >> n;
- int a[n], b[n];
- for(int i = 0; i < n; i++) {
- cin >> a[i];
- }
- for(int i = 0; i < n; i++) {
- cin >> b[i];
- }
- sort(a, a+n);
- sort(b, b+n, greater<int>());
- int prev = a[0] + b[0], f=1;
- for(int i = 1; i < n && f; i++) {
- if(prev != a[i] + b[i]) {
- cout << -1 << endl;
- f=0;
- }
- }
- for(int i = 0; i < n && f; i++) {
- cout << a[i] << " ";
- }
- cout << endl;
- for(int i = 0; i < n && f; i++) {
- cout << b[i] << " ";
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment