This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ld long double
#define vf v[i].first
#define vs v[i].second
const ll MOD = 1e9 + 7;
void print(vector<int> &v) {
	for (auto c:v)
		cout << c << " ";
	cout << "\n";
}
map<pair<int,int>,int>mp1;
map<pair<int,int>,int>mp2;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	ll a;
	cin >> n >> k;
	multiset<ll>v,temp;
	for (int i = 0; i < n+k; ++i) {
		cin >> a;
		v.insert(a);
	}
	temp = v;
	for (auto it = temp.begin(); it != temp.end(); ++it) {
		bool flag = true;
		temp.erase(it);
		auto d = (--temp.end());
		ll sum = *temp.begin()+*d;
		d--;
		for (auto c = ++temp.begin(); c != --temp.end(); ++c) {
			if (*c+*d!=sum) {
				flag = false;
				break;
			}
			d--;
		}
		if (flag)
			break;
		temp = v;
	}
	for (auto c:temp)
		cout << c << " ";
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |