# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
818565 | Soumya1 | Table Tennis (info1cup20_tabletennis) | C++17 | 263 ms | 33740 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>
#ifdef __LOCAL__
#include <debug_local.h>
#endif
using namespace std;
void testCase() {
int n, k;
cin >> n >> k;
vector<int> a(n + k);
for (int &i : a) cin >> i;
sort(a.begin(), a.end());
int N = n + k;
auto check = [&](int s) {
int i = 0, j = N - 1;
vector<int> v;
while (i < j) {
if (a[i] + a[j] == s) {
v.push_back(a[i]);
v.push_back(a[j]);
i++, j--;
} else if (a[i] + a[j] > s) {
j--;
} else {
i++;
}
if (v.size() == n) {
sort(v.begin(), v.end());
for (int i : v) cout << i << " ";
cout << "\n";
exit(0);
}
}
};
if (4 * k >= n) {
for (int i = 0; i < k + 1; i++) {
for (int j = N - 1; j >= N - k - 1; j--) {
check(a[i] + a[j]);
}
}
} else {
map<int, int> cnt;
for (int i = 0; i < 2 * k; i++) {
for (int j = N - 1; j >= N - 2 * k; j--) {
cnt[a[i] + a[j]]++;
}
}
for (auto [x, y] : cnt) {
if (y >= k) check(x);
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
testCase();
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... |