# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
728707 | MilosMilutinovic | Table Tennis (info1cup20_tabletennis) | C++14 | 1126 ms | 5600 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;
int n,k,a[305005];
bool solve(int x)
{
int p=n+k,c=0;
vector<int> ans;
for(int i=1;i<=n+k;i++)
{
while(p>i&&a[i]+a[p]>x) p--;
if(p>i&&a[i]+a[p]==x)
{
ans.push_back(a[i]);
ans.push_back(a[p]);
c++,p--;
}
}
if(c>=n/2)
{
sort(ans.begin(),ans.end());
for(int i=0;i<(int)ans.size();i++) printf("%d ",ans[i]);
return true;
}
return false;
}
signed main()
{
scanf("%d%d",&n,&k);
for(int i=1;i<=n+k;i++) scanf("%d",&a[i]);
sort(a+1,a+n+k+1);
if(n<=k)
{
for(int i=1;i<=n+k;i++) for(int j=i+1;j<=n+k;j++) if(solve(a[i]+a[j])) exit(0);
}
else
{
mt19937 rng(time(0));
while(true)
{
int x=rng()%(n+k)+1;
for(int i=max(1,(n+k-x)-3*(k+1));i<=min(n+k,(n+k-x)+3*(k+1));i++) if(x!=i&&solve(a[x]+a[i])) exit(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... |