# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523964 | mateigg4 | Table Tennis (info1cup20_tabletennis) | C++14 | 3099 ms | 5636 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 nmax 160000
#define int long long
#pragma GCC optimize("O3")
using namespace std;
int v[nmax + 1];
pair<int, int> sol[nmax + 1];
unordered_map<int, int> f;
signed main()
{
//ifstream cin("tabletennis.in");
//ofstream cout("tabletennis.out");
int n, k, i, j, x, y, st, dr, s, p;
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> k;
for (i = 1; i <= n + k; i++)
cin >> v[i];
sort(v + 1, v + n + k + 1);
for (x = 0; x <= 2 * k; x++)
for (y = n + k + 1; y > n - k; y--)
{
if (x + n + k - y <= k && f[v[x + 1] + v[y - 1]] == 0)
{
s = v[x + 1] + v[y - 1];
// cout << s << endl;
p = 0;
st = x + 1, dr = y - 1;
for (i = st; i <= dr; i++)
{
while (dr > i && v[i] + v[dr] > s)
dr--;
if (v[i] + v[dr] == s)
{
sol[p++] = {v[i], v[dr]};
// cout << v[i] << " " << v[dr] << endl;
}
}
if (p >= n / 2)
{
for (i = 0; i < n / 2; i++)
cout << sol[i].first << " ";
for (i = n / 2 - 1; i >= 0; i--)
cout << sol[i].second << " ";
return 0;
}
f[s]++;
}
else
break;
}
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... |