# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
718293 | haxorman | Table Tennis (info1cup20_tabletennis) | C++14 | 494 ms | 288060 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;
#define int long long
const int mxN = 2e5 + 7;
int arr[mxN];
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, k;
cin >> n >> k;
bitset<2000000001> in;
for (int i = 0; i < n + k; ++i) {
cin >> arr[i];
in[arr[i]] = true;
}
if (n <= 4 * k) {
for (int i = 0; i < n + k; ++i) {
cin >> arr[i];
in[arr[i]] = true;
}
assert(n >= 2);
for (int i = 0; i < k + 2; ++i) {
for (int j = n + k - 1; j >= n - 1 && j > i; --j) {
int sum = arr[i] + arr[j];
vector<int> nums;
for (int l = 0; l < n + k; ++l) {
if (sum - arr[l] >= 0 && in[sum - arr[l]]) {
nums.push_back(arr[l]);
}
}
if (nums.size() >= n) {
for (int l = 0; l < n; ++l) {
cout << nums[l] << ' ';
}
cout << "\n";
exit(0);
}
}
}
}
else {
map<int,int> freq;
for (int i = 0; i < 2 * k + 2; ++i) {
for (int j = n + k - 1; j >= n - k - 1; --j) {
int sum = arr[i] + arr[j];
freq[sum]++;
}
}
for (auto p : freq) {
if (p.second >= k) {
int sum = p.first;
vector<int> nums;
for (int l = 0; l < n + k; ++l) {
if (sum - arr[l] >= 0 && in[sum - arr[l]]) {
nums.push_back(arr[l]);
}
}
if (nums.size() >= n) {
for (int l = 0; l < n; ++l) {
cout << nums[l] << ' ';
}
cout << "\n";
exit(0);
}
}
}
}
assert(false);
}
// 1 2 1 2 3
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... |