#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz size()
#define ff first
#define ss second
#define pb push_back
#define pii pair <int, int>
#define dur exit(0)
#define dur1 return(0)
const int N = 2e5 + 5;
int a[N], n, k;
int main () {
// freopen ("input.txt", "r", stdin);
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll sum = 0;
cin >> n >> k;
for (int i = 1; i <= n + k; ++i) {
cin >> a[i];
sum += a[i];
}
if (k == 1) {
for (int i = 1; i <= n + k; ++i) {
vector <int> v;
for (int j = 1; j <= n + k; ++j) {
if (j == i) {
continue;
}
v.pb (a[j]);
}
int kl = v.back() + v[0];
int yok = 0;
for (int i = 0; i < (int)v.sz / 2; ++i) {
if (v[i] + v[(int)v.sz - i - 1] != kl) {
yok = 1;
break;
}
}
if (!yok) {
for (int i : v) {
cout << i << " ";
}
return 0;
}
}
}
else if (n + k <= 18) {
for (int i = 0; i < (1 << (n + k)); ++i) {
if (__builtin_popcount (i) != n) continue;
vector <int> v;
for (int j = 0; j < n + k; ++j) {
if (i>>j&1) v.pb (a[j + 1]);
}
sort (v.begin(), v.end());
int kl = v.back() + v[0];
int yok = 0;
for (int i = 0; i < (int)v.sz / 2; ++i) {
if (v[i] + v[(int)v.sz - i - 1] != kl) {
yok = 1;
break;
}
}
if (!yok) {
for (int i : v) {
cout << i << " ";
}
return 0;
}
}
}
}
# | 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... |