# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1002044 | daffuwu | Table Tennis (info1cup20_tabletennis) | C++14 | 96 ms | 7056 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;
#define fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long n, k, a[156069];
vector<long long> ans, cur;
vector<long long> slv(long long sm)
{
long long i, l, r, buang=0;
vector<long long> ret;
for (l=1, r=n+k; buang<=k && l<r; l++, r--)
{
for (; buang<=k && l<r && a[l]+a[r]!=sm; buang++)
{
if (a[l]+a[r]>sm) r--;
else l++;
}
if (l == r) break;
ret.push_back(l);
ret.push_back(r);
}
sort(ret.begin(), ret.end());
long long sz = ret.size();
long long m = (sz-n)/2;
//hapus m kiri dan m kanan
reverse(ret.begin(), ret.end());
for (i=1; i<=m; i++) ret.pop_back();
reverse(ret.begin(), ret.end());
for (i=1; i<=m; i++) ret.pop_back();
return ret;
}
int main()
{
long long i, j;
scanf("%lld%lld", &n, &k);
for (i=1; i<=n+k; i++)
{
scanf("%lld", a+i);
}
for (i=1; i<=k+1; i++)
{
for (j=n+k; j>=n; j--)
{
if (i<j)
{
cur = slv(a[i]+a[j]);
if (cur.size() == n)
{
ans = cur;
i = k+2;
break;
}
}
}
}
for (auto x:ans) printf("%lld ", a[x]);
printf("\n");
}
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... |