#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1.5e5+505;
int a[N],n,k;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>k;
for(int i=0;i<n+k;++i)
cin>>a[i];
unordered_map<int,int>occ;
int x,c;
for(int fi=0;fi<=k;++fi){
for(int se=max(0,fi+n-2);se<n+k;++se){
x=a[fi]+a[se];
for(int i=fi+1;i<se;++i)
++occ[a[i]];
c=2;
for(int i=fi+1;i<se;++i){
if(2*a[i]>x)break;
if(2*a[i]==x){
if(occ[a[i]]<2)continue;
c+=2;
occ[a[i]]-=2;
}else if(occ[x-a[i]]){
c+=2;
--occ[x-a[i]];
--occ[a[i]];
}
}
if(c>=n){
occ.clear();
for(int i=fi+1;i<se;++i)
occ[a[i]]++;
vector<int>v={a[fi],a[se]};
for(int i=fi+1;i<se;++i){
if(2*a[i]>x)break;
if(2*a[i]==x){
if(occ[a[i]]<2)continue;
v.push_back(a[i]);
v.push_back(a[i]);
occ[a[i]]-=2;
}else if(occ[x-a[i]]){
c+=2;
v.push_back(a[i]);
v.push_back(x-a[i]);
--occ[x-a[i]];
--occ[a[i]];
}
}
sort(v.begin(),v.end());
for(auto&x:v)
cout<<x<<' ';
return 0;
}
occ.clear();
}
}
assert(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... |