# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
667597 | LFFB | Table Tennis (info1cup20_tabletennis) | C++14 | 3107 ms | 691920 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)
typedef long long llong;
const int MAX_N = 16e4;
const int MAX_V = 2e9 + 10;
int n, m, k;
llong sum, th;
int input[MAX_N];
std::map<int, int> map;
int possible;
std::vector<std::pair<int, int>> pairs;
int output[MAX_N];
int main() {
scanf("%d %d", &n, &k);
m = n + k;
for (int i = 0; i < m; i++) {
scanf("%d", &input[i]);
sum += input[i];
}
th = sum / ((n+k) / 2);
std::sort(input, input+n+k);
for (int i = 0; i < m; i++) {
for (int j = i+1; j < m; j++) {
int s = input[i] + input[j];
if (s > th) break;
map[s]++;
}
}
for (std::pair<int, int> pair : map) {
debug("%d %d\n", pair.first, pair.second);
if (pair.second >= n/2) {
possible = pair.first;
break;
}
}
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[2*i ] = pair.first;
output[2*i+1] = pair.second;
}
std::sort(output, output+n);
for (int i = 0; i < n; i++) {
printf("%d ", output[i]);
}
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... |