#include<bits/stdc++.h>
using namespace std;
using ll=long long;
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;
while(l<r){
if(a[l]+a[r]==x)++l,--r,++br;
else if(a[l]+a[r]<x)++l;
else --r;
}
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(auto&xx:v)cout<<xx<<' ';
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... |