# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
299635 | E869120 | Table Tennis (info1cup20_tabletennis) | C++14 | 3012 ms | 4720 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;
int A[1 << 18];
bool used[1 << 18];
bool solve(int border) {
for (int i = 0; i < N + K; i++) used[i] = false;
int cl = 0, cr = N + K - 1, cnt = 0;
while (cl < cr && cnt < (N / 2)) {
if (A[cl] + A[cr] > border) cr--;
else if (A[cl] + A[cr] < border) cl++;
else {
used[cl] = true;
used[cr] = true;
cl += 1;
cr -= 1;
cnt += 1;
}
}
if (cnt == (N / 2)) return true;
return false;
}
int main() {
// Step #1. Input
scanf("%d%d", &N, &K);
for (int i = 0; i < N + K; i++) scanf("%d", &A[i]);
sort(A, A + (N + K));
// Step #2. BruteForce
vector<long long> Cand;
for (int i = 0; i <= K; i++) {
for (int j = 0; j <= K - i; j++) {
Cand.push_back(A[i] + A[N + K - 1 - j]);
}
}
sort(Cand.begin(), Cand.end());
Cand.erase(unique(Cand.begin(), Cand.end()), Cand.end());
// Step #3. Tansaku
for (int i = 0; i < Cand.size(); i++) {
bool I = solve(Cand[i]);
if (I == false) continue;
vector<int> vec;
for (int j = 0; j < N + K; j++) {
if (used[j] == true) vec.push_back(A[j]);
}
for (int j = 0; j < vec.size(); j++) {
if (j) printf(" ");
printf("%d", vec[j]);
}
printf("\n");
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... |