# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
751087 | Stickfish | Table Tennis (info1cup20_tabletennis) | C++17 | 3086 ms | 697244 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 <iostream>
#include <algorithm>
#include <map>
#include <cassert>
#include <vector>
using namespace std;
const int MAXN = 157000;
int a[MAXN];
void solve_slow(int n, int k) {
map<int, int> mp;
for (int i = 0; i < n + k; ++i) {
int ctr = n + k - i - 1;
for (int t = -k - n; t <= k + n; ++t) {
if (ctr + t <= i || ctr + t >= n + k)
continue;
int val = a[i] + a[ctr + t];
++mp[val];
}
}
int mxval = 0;
int mxcnt = 0;
for (auto [val, cnt] : mp) {
if (mxcnt < cnt) {
mxval = val;
mxcnt = cnt;
}
}
assert(mxcnt >= n / 2);
vector<int> ans;
for (int i = 0; i < n + k; ++i) {
int ctr = n + k - i - 1;
for (int t = -k - n; t <= k + n; ++t) {
if (ctr + t <= i || ctr + t >= n + k)
continue;
int val = a[i] + a[ctr + t];
if (val == mxval) {
ans.push_back(a[i]);
ans.push_back(a[ctr + t]);
}
}
}
while (ans.size() > n)
ans.pop_back();
sort(ans.begin(), ans.end());
for (int i = 0; i < n; ++i) {
cout << ans[i] << ' ';
}
cout << '\n';
}
signed main() {
int n, k;
cin >> n >> k;
for (int i = 0; i < n + k; ++i) {
cin >> a[i];
}
if (n * k <= 300000) {
solve_slow(n, k);
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... |