Submission #1100689

#TimeUsernameProblemLanguageResultExecution timeMemory
1100689Kirill22Table Tennis (info1cup20_tabletennis)C++17
0 / 100
54 ms4732 KiB
#include "bits/stdc++.h" using namespace std; void solve() { int n, k; cin >> n >> k; vector<int> a(n + k); for (int i = 0; i < n + k; i++) { cin >> a[i]; } for (int l = 0; l <= k; l++) { for (int r = n + k - 1; r >= n; r--) { if (l >= r) { continue; } int s = a[l] + a[r], cnt = 1; for (int i = l + 1, j = r - 1; i < j; ) { if (cnt + (j - i + 1) / 2 < n / 2) { break; } if (a[i] + a[j] == s) { cnt++; i++, j--; } else if (a[i] + a[j] > s) { j--; } else { i++; } } // cout << l << " " << r << " " << cnt << endl; if (cnt >= n / 2) { vector<int> ans = {a[l], a[r]}; for (int i = l + 1, j = r - 1; (int) ans.size() < n; ) { if (a[i] + a[j] == s) { ans.push_back(a[i]); ans.push_back(a[j]); i++, j--; } else if (a[i] + a[j] > s) { j--; } else { i++; } } std::sort(ans.begin(), ans.end()); for (auto& x : ans) { cout << x << " "; } return; } } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t--) { solve(); } }
#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...