# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
524830 | boykut | Table Tennis (info1cup20_tabletennis) | C++14 | 3107 ms | 758764 KiB |
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 namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> a(n + k);
map<int, int> cnt;
for (int i = 0; i < n + k; i++) {
cin >> a[i];
}
for (int i = 0; i < n + k; i++) {
for (int j = i + 1; j < n + k; j++) {
cnt[a[i] + a[j]]++;
}
}
int mx = -1, sum = -1;
for (auto it : cnt) {
if (it.second > mx)
mx = it.second, sum = it.first;
}
assert(sum != -1);
set<int> st(a.begin(), a.end());
deque<int> ans;
for (int i = 0; i < n + k; i++) {
if (st.count(sum - a[i])) {
ans.push_back(a[i]);
ans.push_back(sum - a[i]);
st.erase(sum - a[i]);
st.erase(a[i]);
}
}
sort(ans.begin(), ans.end());
assert(ans.size() >= n);
while (ans.size() > n) {
ans.pop_back();
ans.pop_front();
}
for (int v : ans)
cout << v << ' ';
return 0;
}
Compilation message (stderr)
# | 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... |