# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
524636 | amin | Table Tennis (info1cup20_tabletennis) | C++14 | 3070 ms | 1484 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 main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long n,k;
cin>>n>>k;
long long a[n+k];
for(long i=0;i<n+k;i++)
{
cin>>a[i];
}
long long sum;
long long j=0;
long long ans=0;
long long p=0;
long long l,r;
for(long i=0;i<=k;i++)
{
for(long y=i+n-1;y<n+k;y++)
{
j=0;
ans=0;
p=0;
sum=a[i]+a[y];
r=y-1;
l=i+1;
ans=2;
while(l<r)
{
if(p>k)
{
break;
}
if(a[l]+a[r]>sum)
{
r--;
p++;
continue;
}
if(a[l]+a[r]<sum)
{
p++;
l++;
continue;
}
if(a[l]+a[r]==sum)
{
ans+=2;
l++;
r--;
if(ans>=n)
{
j=1;
break;
}
continue;
}
}
if(j==1)
{
break;
}
}
if(j==1)
{
break;
}
}
l=0;
r=n+k-1;
ans=0;
p=0;
vector<long long>v;
while(l<r)
{
if(a[l]+a[r]>sum)
{
r--;
continue;
}
if(a[l]+a[r]<sum)
{
p++;
continue;
}
if(a[l]+a[r]==sum)
{
ans+=2;
v.push_back(a[l]);
v.push_back(a[r]);
l++;
r--;
if(ans>=n)
{
j=1;
break;
}
continue;
}
}
sort(v.begin(),v.end());
for(long i=0;i<n;i++)
{
cout<<v[i]<<' ';
}
}
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... |