# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
216191 | Pajaraja | Table Tennis (info1cup20_tabletennis) | C++17 | 626 ms | 5508 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>
#define MAXN 200007
#define MAXK 407
using namespace std;
int a[MAXN],n,k,m;
mt19937 rng(time(NULL));
bool check(int s)
{
int t1=1,t2=m;
vector<pair<int,int> > p;
while(t1<t2)
{
if(a[t1]+a[t2]==s) p.push_back({t1,t2});
if(a[t1]+a[t2]<=s) t1++;
if(a[t1]+a[t2]>s) t2--;
}
if(p.size()<n/2) return false;
for(int i=0;i<n/2;i++) printf("%d ",a[p[i].first]);
for(int i=n/2-1;i>=0;i--) printf("%d ",a[p[i].second]);
return true;
}
int main()
{
scanf("%d%d",&n,&k); m=n+k;
for(int i=1;i<=m;i++) scanf("%d",&a[i]);
if(n>k)
{
bool found=false;
while(!found)
{
int x=rng()%m+1;
for(int i=max(m+1-x-k,1);i<=min(m+1-x+k,m) && !found;i++) found=check(a[i]+a[x]);
}
}
else
{
bool found=false;
for(int i=1;i<=k+1 && !found;i++) for(int j=m;j>=m-k-1 && !found;j--) found=check(a[i]+a[j]);
}
}
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... |