Submission #447487

#TimeUsernameProblemLanguageResultExecution timeMemory
447487raidTable Tennis (info1cup20_tabletennis)C++17
61 / 100
412 ms33808 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; 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)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:45:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |    if ( sol.size() < n ) {
      |         ~~~~~~~~~~~^~~
tabletennis.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   for ( int i = 0; i < sol.size(); ++i ) {
      |                    ~~^~~~~~~~~~~~
#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...