제출 #447529

#제출 시각아이디문제언어결과실행 시간메모리
447529raidTable Tennis (info1cup20_tabletennis)C++17
100 / 100
430 ms32440 KiB
#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, mxs; 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; } } for ( auto it : S ) { if ( it.second == mx ) { mxs.push_back( it.first ); } } for ( int it = 0; it < (int)mxs.size(); ++it ) { int i = 1, j = n + k; sum = mxs[it]; while ( i < j ) { if ( sum == v[i] + v[j] ) { if ( (int)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; } } if ( (int)sol.size() == n ) { break; } sol.clear(); } sort( sol.begin(), sol.end() ); for ( int i = 0; i < (int)sol.size(); ++i ) { cout << sol[i] << " "; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...