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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, m;
vector<int> v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
v.resize(n + m);
for (int i = 0; i < n + m; i++) {
cin >> v[i];
}
vector<int> ans(n);
for (int i = (n / 2) - 1; i <= (n / 2) - 1 + m; i++) {
int s = v[i] + v[i + 1], l = 0, r = n + m - 1, j = 0;
while (l < r and j < n / 2) {
while (r > l and v[l] + v[r] > s) r--;
if (l < r and v[l] + v[r] == s) {
ans[j] = v[l], ans[n - j - 1] = v[r];
j++;
}
l++;
}
if (j < n / 2) continue;
for (int x : ans) {
cout << x << ' ';
}
cout << '\n';
break;
}
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... |