# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1066342 | goduadzesaba | Table Tennis (info1cup20_tabletennis) | C++17 | 170 ms | 8904 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;
#define int long long
const int N=2e5+5,mod=1e9+7;
int n,k,a[N],x,y,sm,ans;
vector <int> v;
map <int,bool> mp;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
srand(time(0));
cin>>n>>k;
for (int i=1; i<=n+k; i++)
cin>>a[i];
sort(a+1,a+n+k+1);
while (1){
x=rand()%(k+1)+1;
y=rand()%(k+1)+n;
sm=a[x]+a[y];
if (mp[sm]) continue;
mp[sm]=1;
v.clear();
x=1; y=n+k; ans=0;
while (x<y && v.size()<n && v.size()+y-x+1>=n){
if (a[x]+a[y]<sm){
x++;
}
else if (a[x]+a[y]>sm){
y--;
}
else{
v.push_back(a[x]);
v.push_back(a[y]);
ans++; x++; y--;
}
}
if (ans>=n/2){
sort(v.begin(),v.end());
for (int i:v) cout<<i<<" ";
return 0;
}
}
}
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... |