#include <bits/stdc++.h>
using namespace std;
#define ort ((bas+son)/2)
#define int long long
#define endl "\n"
int n,k,a[150005],ind;
inline bool check(int l,int r,int sum){
int say=0;
while(l<r){
if(a[l]+a[r]==sum){
l++;
r--;
say++;
}
else if(a[l]+a[r]<sum){
ind=l;
l++;
}
else{
ind=r;
r--;
}
}
if(l==r)ind=l;
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];
if(check(1,n+k,a[1]+a[n+k])){
for(int i=1;i<ind;i++)cout<<a[i]<<" ";
for(int i=ind+1;i<=n+k;i++)cout<<a[i]<<" ";
//~ cout<<"**\n";
//~ cout<<ind<<endl;
return 0;
}
if(check(1,n+k-1,a[1]+a[n+k-1])){
for(int i=1;i<n+k;i++)cout<<a[i]<<" ";
return 0;
}
if(check(2,n,a[2]+a[n+k])){
for(int i=2;i<=n+k;i++)cout<<a[i]<<" ";
return 0;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
604 KB |
Output is correct |
2 |
Incorrect |
12 ms |
3160 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
1368 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |