# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
736793 | stevancv | Table Tennis (info1cup20_tabletennis) | C++14 | 621 ms | 6044 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>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 2e5 + 2;
const ll linf = 1e18;
int a[N], n, k;
void Resi(int x) {
vector<int> v;
int p = n + k - 1;
for (int i = 0; i < n + k - 1; i++) {
while (i < p && a[i] + a[p] > x) p -= 1;
if (i < p && a[i] + a[p] == x) {
v.push_back(a[i]);
v.push_back(a[p]);
p -= 1;
}
}
if (v.size() >= n) {
vector<int> ans;
for (int i = 0; i < n; i++) ans.push_back(v[i]);
sort(ans.begin(), ans.end());
for (int i : ans) cout << i << sp;
cout << en;
exit(0);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for (int i = 0; i < n + k; i++) cin >> a[i];
if (n <= k) for (int i = 0; i < n + k; i++) for (int j = i + 1; j < n + k; j++) Resi(a[i] + a[j]);
mt19937 mt(time(nullptr));
while (1) {
int x = mt() % (n + k);
int mn = max(0, x - k);
int mx = min(n - 1, x);
mn = n - mn - 1;
mx = n - mx - 1;
int l = mx;
int r = mn + k;
for (int i = l; i <= r; i++) if (i != x) Resi(a[i] + a[x]);
}
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... |