# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523394 | Ahmed2me | Table Tennis (info1cup20_tabletennis) | C++17 | 3084 ms | 29248 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,m;
int a[200020];
int main()
{
scanf("%d",&n);scanf("%d",&m);set<int>st;
for(int i=1;i<=n+m;i++){scanf("%d",&a[i]);}
if(n <= 4 * m)
{
for(int i = 1; i <= n + m; ++i){
for(int j = i + 1; j <= n + m; ++j){
{
int sum=a[i]+a[j];
int i=1,j=n+m;
vector<int>ans;
int counter=false;
while(i<j)
{
if(counter>=(n/2)){break;}
if(a[i]+a[j]==sum){counter++;ans.push_back(a[i]);ans.push_back(a[j]);i++;j--;}
else if(a[i]+a[j]>sum){j--;}
else if(a[i]+a[j]<sum){i++;}
}
if(counter==(n/2))
{
sort(ans.begin(),ans.end());
for(int i=0;i<ans.size();i++){printf("%d%c",ans[i],' ');}
return 0;
}
}
}
}
return 0;
}
for(int i=1;i<=min(n,2*m);i++)
{
for(int j=max(1,(n-m+1));j<=n+m;j++)
{
st.insert((a[i]+a[j]));
}
}
for(auto I:st)
{
int sum=I;
int i=1,j=n+m;
vector<int>ans;
int counter=false;
while(i<j)
{
if(counter>=(n/2)){break;}
if(a[i]+a[j]==sum){counter++;ans.push_back(a[i]);ans.push_back(a[j]);i++;j--;}
else if(a[i]+a[j]>sum){j--;}
else if(a[i]+a[j]<sum){i++;}
}
if(counter==(n/2))
{
sort(ans.begin(),ans.end());
for(int i=0;i<ans.size();i++){printf("%d%c",ans[i],' ');}
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... |