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;
const int MAX = 2e6 + 50;
const int INF = 0x3f3f3f3f;
int n, k, tot, ans;
vector<ll> v;
void bt(int i, int chosen, vector<ll> aux){
if(chosen > n || i > tot) return;
if(chosen + (tot - i) < n) return;
if(i == tot){
if(chosen == n){
ll sum = aux[0] + aux[aux.size() - 1];
bool isAns = true;
for(int l = 1, r = aux.size() - 2; l < r; l++, r--)
if(aux[l] + aux[r] != sum){ isAns = false; break; }
if(isAns){
for(auto x : aux)
cout << x << ' ';
cout << '\n';
exit(0);
}
}
return;
}
vector<ll> sla = aux;
sla.push_back(v[i]);
bt(i + 1, chosen + 1, sla);
bt(i + 1, chosen, aux);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
tot = n + k;
for(int i = 0; i < tot; i++){
ll x; cin >> x;
v.push_back(x);
}
vector<ll> trash;
bt(0, 0, trash);
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... |