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 ort ((bas+son)/2)
#define int long long
#define endl "\n"
int n,k,a[200005],ind;
bool vis[200005],viss[200005],viss2[200005];
inline bool check(int l,int r,int sum){
int say=0;
while(l<r){
//~ if(vis[l]){l++;continue;}
//~ if(vis[r]){r--;continue;}
if(a[l]+a[r]==sum && !viss[l] && !viss[r] && !viss2[l] && !viss2[r]){
l++;
r--;
say++;
}
else if(a[l]+a[r]<sum){
ind=l;
vis[l]=1;
l++;
}
else{
ind=r;
vis[r]=1;
r--;
}
}
if(l==r){ind=l;vis[l]=1;}
if(say>=n/2)return 1;
return 0;
}
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>k;
for(int i=1;i<=n+k;i++)cin>>a[i];
for(int i=1;i<=k+1;i++){
viss[i-1]=1;
memset(viss2,0,sizeof(viss2));
for(int j=n;j>=n-k;j--){
viss2[j+1]=1;
if(i>=j)break;
memset(vis,0,sizeof(vis));
if(check(1,n+k,a[i]+a[j])){
//~ cout<<a[i]+a[j]<<endl;
for(int ii=1;ii<=n+k;ii++){
if(vis[ii])continue;
cout<<a[ii]<<" ";
}
return 0;
}
}
}
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... |