Submission #667589

#TimeUsernameProblemLanguageResultExecution timeMemory
667589LFFBTable Tennis (info1cup20_tabletennis)C++14
49 / 100
3107 ms731116 KiB
#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)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
tabletennis.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d", &input[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...