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;
#define Baytoro_MayrambekovOrz void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define int long long
int n,k;
vector<int> vec,ans;
bool check(int x){
int i;
int cnt=0;
ans.clear();
int r=n+k-1;
for(i=0;i<r && cnt<n/2;i++){
while(r>i && vec[i]+vec[r]>x)
r--;
if(r>i && vec[i]+vec[r]==x){
cnt++;
ans.pb(vec[i]);
ans.pb(vec[r]);
}
}
return n/2==cnt;
}
int a,b,c,m,j,x,y,cnt=0,sum=0,res=0;
Baytoro_MayrambekovOrz{
int i;
cin>>n>>k;
vec.resize(n+k);
for(i=0;i<n+k;i++){
cin>>vec[i];
}
for(i=0;i<=min(k*2,n+k);i++){
for(j=max(0ll,n-k);j<n+k;j++){
if(check(vec[i]+vec[j])){
sort(all(ans));
for(auto it: ans)
cout<<it<<' ';
return;
}
}
}
}
main(){
ios;
int T=1;
//cin>>T;
while(T--){
solve();
}
}
Compilation message (stderr)
tabletennis.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
50 | main(){
| ^~~~
# | 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... |