이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |