# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386562 | fadi57 | Table Tennis (info1cup20_tabletennis) | C++14 | 755 ms | 5476 KiB |
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;
const int mx=2e5+10;
typedef long long ll;
const int inf=1e9+3e5;
int a[mx];
map<int,int>mp;int n,k,z;
bool check(int s){
int l=0;int r=z-1;
int cnt=n/2;
while(l<r){
if(cnt==0){break;}
if(((r-l+1)/2)<cnt){break;}
if(a[l]+a[r]>s){r--;}
else if(a[l]+a[r]<s){l++;} else{
l++;
r--;
cnt--;
}
}
if(cnt==0){return 1;}
return 0;
}
int main(){
cin>>n>>k; z=n+k;
for(int i=0;i<n+k;i++){
cin>>a[i];
}
/*
3 1
1 1 1 1*/
int teams=n/2;
int aa;int bb;
vector<int>v;
for(int i=0;i<=k;i++){
for(int j=n-1;j<z;j++){
v.push_back(a[i]+a[j]);
}
}
sort(v.begin(),v.end());
int sum;
for(auto it:v){
if(check(it)){
sum=it;break;
}
}//cout<<sum;
int l=0;int r=z-1;
int cnt=n/2;
vector<int>o;
while(l<r){
if(cnt==0){break;}
if(a[l]+a[r]>sum){r--;}
else if(a[l]+a[r]<sum){l++;} else{
// cout<<a[l]<<" "<<a[r]<<" ";
o.push_back(a[l]); o.push_back(a[r]);
l++;
r--;
cnt--;
}
}sort(o.begin(),o.end());
for(auto it:o){
cout<<it<<" ";
}
}
Compilation message (stderr)
# | 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... |