# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447487 | raid | Table Tennis (info1cup20_tabletennis) | C++17 | 412 ms | 33808 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 <algorithm>
#include <map>
using namespace std;
const int MAX = 150402;
int v[MAX];
map<int, int> S;
vector<int> sol;
int main() {
int n, k;
cin >> n >> k;
for ( int i = 1; i <= n + k; ++i ) {
cin >> v[i];
}
sort( v + 1, v + n + k + 1 );
if ( n + k >= 4 * k + 3 ) {
for ( int i = 1; i <= 2 * k + 1; ++i ) {
for ( int j = n + k; j >= n - k; --j ) {
++S[v[i] + v[j]];
}
}
} else {
for ( int i = 1; i <= n + k; ++i ) {
for ( int j = i + 1; j <= n + k; ++j ) {
++S[v[i] + v[j]];
}
}
}
int sum = 0, mx = 0;
for ( auto it : S ) {
if ( mx < it.second ) {
mx = it.second;
sum = it.first;
}
}
int i = 1, j = n + k;
while ( i < j ) {
if ( sum == v[i] + v[j] ) {
if ( sol.size() < n ) {
sol.push_back( v[i] );
sol.push_back( v[j] );
}
++i;
--j;
} else if ( sum < v[i] + v[j] ) {
--j;
} else {
++i;
}
}
sort( sol.begin(), sol.end() );
for ( int i = 0; i < sol.size(); ++i ) {
cout << sol[i] << " ";
}
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... |