Submission #683517

#TimeUsernameProblemLanguageResultExecution timeMemory
683517JooDdaeTable Tennis (info1cup20_tabletennis)C++17
58 / 100
57 ms8016 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int n, k, a[200200]; int main(){ cin.tie(0)->sync_with_stdio(0); cin >> n >> k; for(int i=1;i<=n+k;i++) cin >> a[i]; map<int, int> mp; for(int A=0;A<=k;A++) for(int B=0;B<=k;B++) { int L = A+1, R = n+k-B; mp[a[L] + a[R]]++; } for(auto [S, c] : mp) if(5*k >= n || c >= k/2) { int l = 1, r = n+k; vector<array<int, 2>> v; while(l < r && v.size()+(r-l+1)/2 >= n/2) { if(a[l] + a[r] == S) { v.push_back({l, r}); l++, r--; continue; } if(S-a[l] > a[r]) l++; else r--; } if(v.size() >= n/2) { for(int i=0;i<n/2;i++) cout << a[v[i][0]] << " "; for(int i=n/2-1;i>=0;i--) cout << a[v[i][1]] << " "; return 0; } } }

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:21:43: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |         while(l < r && v.size()+(r-l+1)/2 >= n/2) {
      |                        ~~~~~~~~~~~~~~~~~~~^~~~~~
tabletennis.cpp:32:21: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |         if(v.size() >= n/2) {
      |            ~~~~~~~~~^~~~~~
#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...