# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
667589 | LFFB | Table Tennis (info1cup20_tabletennis) | C++14 | 3107 ms | 731116 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 <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define debug(args...) //printf(args)
const int MAX_N = 16e4;
const int MAX_V = 2e9 + 10;
int n, m, k;
int input[MAX_N];
std::map<int, int> map;
int possible;
std::vector<std::pair<int, int>> pairs;
std::vector<int> output;
int main() {
scanf("%d %d", &n, &k);
m = n + k;
for (int i = 0; i < m; i++) {
scanf("%d", &input[i]);
}
for (int i = 0; i < m; i++) {
for (int j = i+1; j < m; j++) {
map[input[i] + input[j]]++;
}
}
for (std::pair<int, int> pair : map) {
debug("%d %d\n", pair.first, pair.second);
if (pair.second >= n/2) {
possible = pair.first;
}
}
debug("chose %d\n", possible);
for (int i = 0; i < m; i++) {
for (int j = i+1; j < m; j++) {
if (input[i] + input[j] == possible) {
pairs.push_back({input[i], input[j]});
}
}
}
debug("got %d pairs\n", (int)pairs.size());
for (int i = 0; i < n/2; i++) {
std::pair<int, int> pair = pairs[i];
debug("inserting %d and %d\n", pair.first, pair.second);
output.push_back(pair.first);
output.push_back(pair.second);
}
std::sort(output.begin(), output.end());
for (int x : output) {
printf("%d ", 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... |