제출 #1100687

#제출 시각아이디문제언어결과실행 시간메모리
1100687Kirill22Table Tennis (info1cup20_tabletennis)C++17
9 / 100
16 ms2388 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 - 1; r >= n - k - 1; 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++; } } 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...