# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
342636 | ogibogi2004 | Table Tennis (info1cup20_tabletennis) | C++14 | 371 ms | 34016 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 MAXN=200002;
int n,k;
int a[MAXN];
bool found=0;
map<int,int> mp;
void check(int s)
{
vector<int>v1,v2;
int l=1,r=n+k;
while(l<r)
{
if(v1.size()+v2.size()==n)break;
if(a[l]+a[r]==s)
{
v1.push_back(a[l]);
v2.push_back(a[r]);
++l;--r;
}
else
{
if(a[l]+a[r]>s)
{
--r;
}
else ++l;
}
}
if(v1.size()+v2.size()<n)return;
reverse(v2.begin(),v2.end());
found=1;
for(auto xd:v1)cout<<xd<<" ";
for(auto xd:v2)cout<<xd<<" ";
cout<<"\n";
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>k;
for(int i=1;i<=n+k;++i)
{
cin>>a[i];
}
for(int i=1;i<=2*k;++i)
{
for(int j=n-k;j<=n+k;++j)
{
++mp[a[i]+a[j]];
}
}
for(auto xd:mp)
{
if(xd.second<k)continue;
check(xd.first);
if(found)return 0;
}
if(n>MAXN/2)assert(false);
for(auto xd:mp)
{
check(xd.first);
if(found)return 0;
}
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... |