# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
690772 | MateiKing80 | Table Tennis (info1cup20_tabletennis) | C++14 | 63 ms | 6552 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;
int n,k,a[150500];
unordered_map<int,bool>ok;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> k;
for (int i = 1; i <= n + k; i++)
cin >> a[i];
sort(a + 1,a + n + k + 1);
for (int i = 1; i <= k + 1; i++)
{
for (int j = n + k; j >= n - 1; j--)
{
int sum = a[i] + a[j];
if(ok[sum])
break;
ok[sum]=true;
int st = i + 1,dr = j - 1;
vector<int>sol;
sol.push_back(a[i]);
sol.push_back(a[j]);
while (st < dr && sol.size() < n && dr-st+1>=n-sol.size())
{
if (a[st] + a[dr] == sum)
{
sol.push_back(a[st]);
sol.push_back(a[dr]);
st++;
dr--;
}
else if (a[st] + a[dr] > sum)
dr--;
else
st++;
}
if (sol.size() == n)
{
sort(sol.begin(),sol.end());
for (int j = 0; j < n; j++)
cout << sol[j] << ' ';
return 0;
}
}
}
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... |