Submission #791055

#TimeUsernameProblemLanguageResultExecution timeMemory
791055AndreyTable Tennis (info1cup20_tabletennis)C++14
0 / 100
131 ms4504 KiB
#include <bits/stdc++.h> using namespace std; int n,k; vector<int> ans(0); vector<int> haha(0); bool check(int a) { ans.clear(); int l = 0,r = n+k-1; while(l < r) { while(r > l && haha[l]+haha[r] > a) { r--; } if(r <= l) { return false; } if(haha[r]+haha[l] == a) { ans.push_back(haha[l]); ans.push_back(haha[r]); if(ans.size() == n) { return true; } } l++; } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; int a; for(int i = 0; i < n+k; i++) { cin >> a; haha.push_back(a); } for(int i = 0; i < k; i++) { for(int j = n+k-1; j >= n && j > i; j--) { if(check(haha[i]+haha[j])) { sort(ans.begin(),ans.end()); for(int y = 0; y < n; y++) { cout << ans[y] << " "; } return 0; } } } return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'bool check(int)':
tabletennis.cpp:21:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |             if(ans.size() == n) {
      |                ~~~~~~~~~~~^~~~
#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...