# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
679439 | alexdd | Table Tennis (info1cup20_tabletennis) | C++17 | 3085 ms | 329908 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.
#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
unordered_map<int,int> fr;
unordered_map<int,int> fr1;
int mxm,unde;
int a[160001];
vector<int> rez;
void npat()
{
for(int i=1;i<=n+k;i++)
{
for(int j=1;j<i;j++)
{
fr[a[i]+a[j]]++;
if(fr[a[i]+a[j]] > mxm)
{
mxm = fr[a[i]+a[j]];
unde = a[i]+a[j];
}
}
}
for(int i=1;i<=n+k;i++)
{
if(a[i]<unde-a[i] && fr1[unde-a[i]]>0 && rez.size()<n)
{
rez.push_back(a[i]);
rez.push_back(unde-a[i]);
}
}
sort(rez.begin(),rez.end());
for(int i=0;i<n;i++)
cout<<rez[i]<<" ";
}
bool verif(int unde)
{
int cnt=0;
for(int i=1;i<=n+k;i++)
{
if(a[i]<unde-a[i] && fr1[unde-a[i]]>0)
{
cnt+=2;
}
}
if(cnt>=n)
return 1;
return 0;
}
void afiseaza(int unde)
{
for(int i=1;i<=n+k;i++)
{
if(a[i]<unde-a[i] && fr1[unde-a[i]]>0 && rez.size()<n)
{
rez.push_back(a[i]);
rez.push_back(unde-a[i]);
}
}
sort(rez.begin(),rez.end());
for(int i=0;i<n;i++)
cout<<rez[i]<<" ";
}
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>k;
for(int i=1;i<=n+k;i++)
{
cin>>a[i];
fr1[a[i]]++;
}
if(n<=2000)
npat();
else
{
sort(a+1,a+1+n+k);
for(int i=0;i<=k;i++)
{
for(int j=0;i+j<=k;j++)
{
if(verif(a[i+1]+a[n+k-j]))
{
afiseaza(a[i+1]+a[n+k-j]);
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... |