# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
418202 | dolphingarlic | Table Tennis (info1cup20_tabletennis) | C++14 | 109 ms | 5184 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>
typedef long long ll;
using namespace std;
int n, k;
ll a[150401];
void check(int pref, int suff) {
vector<int> res;
int lptr = pref + 1, rptr = suff - 1, bad = pref + n + k + 1 - suff;
ll target = a[lptr] + a[rptr];
while (lptr < rptr) {
int sm = a[lptr] + a[rptr];
if (sm == target) {
res.push_back(lptr), res.push_back(rptr);
lptr++, rptr--;
if (res.size() == n) {
sort(res.begin(), res.end());
for (int i : res) cout << a[i] << ' ';
exit(0);
}
} else if (sm < target)
lptr++, bad++;
else
rptr--, bad++;
if (bad > k) return;
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> k;
for (int i = 1; i <= n + k; i++) cin >> a[i];
for (int i = 0; i <= k; i++)
for (int j = 0; j <= k - i; j++) check(i, n + k + 1 - j);
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... |