제출 #315760

#제출 시각아이디문제언어결과실행 시간메모리
315760jungsnowTable Tennis (info1cup20_tabletennis)C++14
100 / 100
386 ms32668 KiB
#include<bits/stdc++.h> using namespace std; const int N = 155010; int n, k, a[N]; map<int, int> mp; bool check(int sum) { vector <int> L, R; int l = 1, r = n + k, cn = 0; while (l < r) { if (a[l] + a[r] > sum) { if (cn == k) return 0; --r; ++cn; } else if (a[l] + a[r] < sum) { if (cn == k) return 0; ++l; ++cn; } else { L.push_back(a[l]); R.push_back(a[r]); ++l; --r; } } for (int x : L) cout<<x<<' '; reverse(R.begin(), R.end()); for (int x : R) cout<<x<<' '; return 1; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i = 1; i <= n + k; ++i) { cin >> a[i]; } if (n <= 3 * k) { for (int i = 1; i < n + k; ++i) { for (int j = i + 1; j <= n + k; ++j) { if (check(a[i] + a[j])) { return 0; } } } } else { for (int i = 1; i <= 2 * k; ++i) { for (int j = n - k + 1; j <= n + k; ++j) { mp[a[i] + a[j]]++; } } for (auto &ele : mp) { if (ele.second >= k) { if (check(ele.first)) return 0; } } } }
#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...