Submission #1001099

#TimeUsernameProblemLanguageResultExecution timeMemory
1001099kachim2Table Tennis (info1cup20_tabletennis)C++17
0 / 100
3089 ms10112 KiB
#include <algorithm> #include <bits/stdc++.h> #include <cstdint> #include <vector> using namespace std; vector<pair<int, int>> check_balanced(vector<int> in, int val) { set<int> s; for (int i : in){ s.insert(i); } vector<pair<int, int>> res; for (int i : in){ if(s.count(val-i) && s.count(i) && i!=val-i){ s.erase(i); s.erase(val-i); res.emplace_back(i, val-i); } } return res; } int main() { int N, K; cin >> N >> K; vector<int> input(N+K); for(int i = 0; i < N+K; i++){ cin >> input[i]; } sort(input.begin(), input.end()); for(int i = 0; i < K; i++){ for(int j = 0; j + i < K; j++){ const int sp = N+K-j-1; auto a = check_balanced(input, input[i]+input[j]); if(a.size()>=N/2){ vector<int> out; for(auto i : a){ out.push_back(i.first); out.push_back(i.second); } sort(out.begin(), out.end()); for(int i : out){ cout << i <<' '; } return 0; } } } }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:35:19: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |        if(a.size()>=N/2){
      |           ~~~~~~~~^~~~~
tabletennis.cpp:33:17: warning: unused variable 'sp' [-Wunused-variable]
   33 |       const int sp = N+K-j-1;
      |                 ^~
#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...