Submission #418195

#TimeUsernameProblemLanguageResultExecution timeMemory
418195dolphingarlicTable Tennis (info1cup20_tabletennis)C++14
72 / 100
3059 ms4592 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; int n, k, a[150401]; void check(int pref, int suff) { vector<int> res; int lptr = pref + 1, rptr = suff - 1; int target = a[lptr] + a[rptr]; while (lptr < rptr) { int sm = a[lptr] + a[rptr]; if (sm == target) { res.push_back(lptr), res.push_back(rptr); lptr++, rptr--; } else if (sm < target) lptr++; else rptr++; } if (res.size() == n) { sort(res.begin(), res.end()); for (int i : res) cout << a[i] << ' '; exit(0); } } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> k; for (int i = 1; i <= n + k; i++) cin >> a[i]; for (int i = 0; i <= k; i++) for (int j = 0; j <= k - i; j++) check(i, n + k + 1 - j); return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'void check(int, int)':
tabletennis.cpp:19:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     if (res.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...