Submission #418202

#TimeUsernameProblemLanguageResultExecution timeMemory
418202dolphingarlicTable Tennis (info1cup20_tabletennis)C++14
100 / 100
109 ms5184 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; int n, k; ll a[150401]; void check(int pref, int suff) { vector<int> res; int lptr = pref + 1, rptr = suff - 1, bad = pref + n + k + 1 - suff; ll 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--; if (res.size() == n) { sort(res.begin(), res.end()); for (int i : res) cout << a[i] << ' '; exit(0); } } else if (sm < target) lptr++, bad++; else rptr--, bad++; if (bad > k) return; } } 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:18:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |             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...