이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
const int nmax = 150000;
const int kmax = 400;
int a[nmax + kmax];
int n, k;
pair < int, int > ans[nmax / 2];
int check ( int sum ) {
int st = 0, dr = n + k - 1, cnt = 0;
while ( st < dr && cnt < n / 2 && ( dr - st + 1 ) / 2 + cnt >= n / 2 ) {
if ( a[st] + a[dr] == sum )
ans[cnt++] = { st++, dr-- };
else if ( a[st] + a[dr] < sum )
st++;
else dr--;
}
return cnt >= n / 2;
}
int main() {
cin >> n >> k;
for ( int i = 0; i < n + k; i++ )
cin >> a[i];
bool ok = false;
for ( int i = 0; i <= k && !ok; i++ )
for ( int j = n - 1; j < n + k && !ok; j++ )
if ( i < j && check ( a[i] + a[j] ) )
ok = true;
for ( int i = 0; i < n / 2; i++ )
cout << a[ans[i].first] << ' ';
for ( int i = n / 2 - 1; i >= 0; i-- )
cout << a[ans[i].second] << ' ';
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... |