# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
769531 | borisAngelov | Table Tennis (info1cup20_tabletennis) | C++17 | 95 ms | 4564 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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int maxn = 200005;
int n, k;
int a[maxn];
vector<int> solution;
bool check(int i, int j)
{
solution.clear();
int lp = i;
int rp = j;
int sum = a[lp] + a[rp];
solution.push_back(a[lp]);
solution.push_back(a[rp]);
++lp;
--rp;
while (rp - lp >= 1 && solution.size() <= n - 1)
{
if (rp - lp + 1 + solution.size() <= n - 1)
{
return false;
}
if (a[lp] + a[rp] == sum)
{
solution.push_back(a[lp]);
solution.push_back(a[rp]);
++lp;
--rp;
continue;
}
if (a[lp] + a[rp] < sum)
{
++lp;
continue;
}
if (a[lp] + a[rp] > sum)
{
--rp;
continue;
}
}
return solution.size() == n;
}
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
cin >> n >> k;
for (int i = 1; i <= n + k; ++i)
{
cin >> a[i];
}
for (int i = 1; i <= n; ++i)
{
for (int j = n + k; j >= n + i - 1; --j)
{
if (check(i, j) == true)
{
sort(solution.begin(), solution.end());
for (auto idx : solution)
{
cout << idx << ' ';
}
cout << endl;
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... |