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 <set>
using namespace std;
int n, m, a[200005];
set<int> s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for (int i = 0; i < n + m; i++) {
cin >> a[i];
s.insert(a[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 = a[i] + a[j];
int cnt = 0;
for (int k = 0; k < n + m; k++) {
if (s.find(total - a[k]) != s.end()) cnt++;
}
if (cnt >= n) {
cnt = n;
for (int k = 0; k < n + k; k++) {
if (not cnt) break;
if (s.find(total - a[k]) != s.end()) {
cout << a[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... |