# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
686601 | alexdumitru | Table Tennis (info1cup20_tabletennis) | C++14 | 3077 ms | 4680 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 <vector>
#include <algorithm>
using namespace std;
const int NMAX = 150000;
int n, k;
int a[NMAX + 401];
vector<int> v1, v2;
bool works(int sum)
{
v1.clear();
v2.clear();
int cnt = 0;
int j = n + k;
for(int i = 1; i <= n + k; i++)
{
for(; j >= 1 && a[i] + a[j] > sum; j--);
if(i >= j)
break;
if(a[i] + a[j] == sum)
{
cnt++;
v1.push_back(a[i]);
v2.push_back(a[j]);
if(cnt == n / 2)
break;
}
}
return cnt == n / 2;
}
void solve()
{
cin >> n >> k;
for(int i = 1; i <= n + k; i++)
cin >> a[i];
sort(a + 1, a + n + k + 1);
bool ok = false;
for(int i = 1; i <= k + 1 && ok == false; i++)
for(int j = n; j <= n + k && ok == false; j++)
if(works(a[i] + a[j]))
ok = true;
for(int i = 0; i < n / 2; i++)
cout << v1[i] << ' ';
for(int i = n / 2 - 1; i >= 0; i--)
cout << v2[i] << ' ';
cout << '\n';
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
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... |