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 ll = long long;
const int MAX_N = 15 * 1e4;
const int MAX_K = 400;
int a[1 + MAX_N + MAX_K], answer[1 + MAX_N];
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
int n, k;
std::cin >> n >> k;
for (int i = 0; i < n + k; i++) {
std::cin >> a[i];
}
for (int i = 0; i < k + 1; i++) {
bool ok = false;
for (int j = n + i - 1; j < n + k; j++) {
int elim = j - (n + i - 1);
int l = i, r = j;
int sum = a[l] + a[r];
answer[1] = a[l];
answer[n] = a[r];
l++;
r--;
int m = 1;
while (l < r && elim >= 0) {
if (a[l] + a[r] == sum) {
m++;
answer[m] = a[l];
answer[n - m + 1] = a[r];
l++;
r--;
} else if (a[l] + a[r] < sum) {
l++;
elim--;
} else {
r--;
elim--;
}
}
if (m == n / 2) {
ok = true;
break;
}
}
if (ok) {
break;
}
}
for (int i = 1; i <= n; i++) {
std::cout << answer[i] << " ";
}
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... |