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;
#define st first
#define nd second
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
int N=n+k;
vector<int>a(N);
vector<bool>b(2000000001,true);
for(int i=0;i<N;i++)
{
cin>>a[i];
}
for(int i=0;i<k+1;i++)
{
for(int j=0;j+i<k+1;j++)
{
int ile=0,co=a[i]+a[N-j-1];
if(b[co])
{
b[co]=false;
int start=i,meta=N-j-1;
vector<int>c(n);
for(int o=0;i+j+o<=k && start<meta;o++)
{
if(a[start]+a[meta]==co)
{
o--;
c[ile]=a[start];
c[n-ile-1]=a[meta];
ile++;
start++;
meta--;
if(ile==n/2)
{
break;
}
}
else
{
if(a[start]+a[meta]>co)
{
meta--;
}
else
{
start++;
}
}
}
if(ile>=n/2)
{
for(int w=0;w<n;w++)
{
cout<<c[w]<<" ";
}
cout<<endl;
return 0;
}
}
}
}
}
# | 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... |