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];
}
bool done = 0;
for (int i = 0; i <= m + 1; i++) {
for (int j = n + m - 1; j >= max(i + 1, n - 1); j--) {
int total = v[i] + v[j];
int cnt = 0;
for (int k = 0; k < n + m; k++) {
if (binary_search(v.begin(), v.end(), total - v[k])) cnt++;
}
if (cnt >= n) {
cnt = n;
for (int k = 0; k < n + k; k++) {
if (not cnt) break;
if (binary_search(v.begin(), v.end(), total - v[k])) {
cout << v[k] << ' ';
cnt--;
}
}
cout << '\n';
done = 1;
break;
}
}
if (done) 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... |