#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#pragma ("reroll")
#define skip continue;
#define gold ios_base::sync_with_stdio(false);cin.tie(NULL);
#define xa "\n"
#define int long long
#define all(a) a.begin(), a.end()
#define pb push_back
#define F first
#define S second
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5 + 7;
const int MAX = 1e9;
const int inf = 1e18;
int gcd(int a, int b) { if (b == 0) return a; else if(a == 0) return b; else return gcd(b, a % b); }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void solve() {
int n, k;
cin >> n >> k;
int a[n + k + 1];
for(int i = 1; i <= n + k; i++){
cin >> a[i];
}
if(n + k <= 20){
int b[n + k];
for(int i = 1; i <= n + k; i++){
b[i - 1] = a[i];
}
sort(b, b + n + k);
for(int msk = 0; msk < (1 << (n + k)); msk++){
int cnt = 0;
for(int i = 0; i < n + k; i++){
if(msk & (1 << i)){
cnt++;
}
}
if(cnt != k){
skip;
}
vector < int > v;
for(int i = 0; i < n + k; i++){
if(!(msk & (1 << i))){
v.pb(b[i]);
}
}
set < int > ms;
for(int i = 0; i < v.size() / 2; i++){
ms.insert(v[i] + v[v.size() - 1 - i]);
}
if(ms.size() == 1){
for(int x : v){
cout << x << ' ';
}
return;
}
}
}
else if(k == 1){
sort(a + 1, a + n + k + 1);
for(int i = 1; i <= n + k; i++){
vector < int > v;
for(int j = 1; j <= n + k; j++){
if(i == j) skip;
v.pb(a[j]);
}
set < int > ms;
for(int j = 0; j < v.size() / 2; j++){
ms.insert(v[j] + v[v.size() - 1 - j]);
}
if(ms.size() == 1){
for(int x : v){
cout << x << ' ';
}
return;
}
}
}
}
signed main() {
gold;
//freopen("sum2.in", "r", stdin);
//freopen("sum2.out", "w", stdout);
int t = 1;
int ti = 1;
//cin >> t;
while (t--) {
//cout << "Case " << ti << ": ";
solve();
ti++;
}
}
# | 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... |