#include "bits/stdc++.h"
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O3")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,ull>pairull;
typedef pair<ll,pairll>pair3l;
typedef long double ld;
typedef pair<ld,ll>pairld;
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define N 100007
//#define MOD 998244353
#define INF 100000000000007
#define eps 0.0000000001
ll n,k,d[2*N],s[2*N];
ll S(ll x){
ll res=0;
for(int i=1;i<=n+k;i++){
s[i]=0;
}
ll l=1;
ll r=n+k;
while(l<r){
if(d[l]+d[r]<x)l++;
else if(d[l]+d[r]>x)r--;
else{
res+=2;
s[l]=1;
s[r]=1;
l++;
r--;
}
if(res==n)return 1;
}
return 0;
}
int main(){
cin>>n>>k;
for(int i=1;i<=n+k;i++){
cin>>d[i];
}
sort(d+1,d+1+n+k);
ll fl=0;
for(int i=1;i<=n+k;i++){
for(int j=n+k;j>i;j--){
if(j-i+1>n){
if(S(d[i]+d[j])==1){
fl=1;
break;
}
}else break;
}
if(fl==1)break;
}
for(int i=1;i<=n+k;i++){
if(s[i]==1)cout<<d[i]<<" ";
}
//cout<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
720 KB |
Output is correct |
2 |
Incorrect |
56 ms |
2548 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
55 ms |
2596 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
131 ms |
296 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |