#include<bits/stdc++.h>
using namespace std;
using ll=long long;
//JEBAO ME OJUZ VEC 15 MINUTA POKUSAVAM DA POSALJEM
const int N=1.5e5,K=405;
int a[N+K],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];
for(int i=0;i<=k;++i){
for(int j=i+n-1;j<n+k;++j){
int x=a[i]+a[j],l=i+1,r=j-1,br=1,losi=0;
while(l<r&&losi<=k&&br<n/2){
if(a[l]+a[r]==x)++l,--r,++br;
else if(a[l]+a[r]<x)++l,++losi;
else --r,++losi;
}
if(br>=n/2){
vector<int>v={a[i],a[j]};
l=i+1,r=j-1;
while(l<r){
if(a[l]+a[r]==x){
v.push_back(a[l]);
v.push_back(a[r]);
++l,--r;
}else if(a[l]+a[r]<x)++l;
else --r;
}
sort(v.begin(),v.end());
for(int i=0;i<n;++i)cout<<v[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... |