Submission #364287

#TimeUsernameProblemLanguageResultExecution timeMemory
364287AlexandruabcdeTable Tennis (info1cup20_tabletennis)C++14
100 / 100
94 ms3424 KiB
#include <bits/stdc++.h> using namespace std; constexpr int NMAX = 2e5; int N, K; int a[NMAX]; bool ok = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> K; for (int i = 1; i <= N+K; ++ i ) { cin >> a[i]; } sort(a+1, a+N+K+1); for (int i = 1; i <= K+1; ++ i ) { for (int j = N+K; j >= N; -- j ) { int cnt_per = 0; int st = i, dr = j; vector <int> st_s, dr_s; while (st < dr && (dr - st + 1) / 2 + cnt_per >= N/2 && cnt_per < N/2) { if (a[st] + a[dr] == a[i] + a[j]) { st_s.push_back(st); dr_s.push_back(dr); ++ st; -- dr; cnt_per++; } else if (a[st] + a[dr] > a[i] + a[j]) -- dr; else ++ st; } if (cnt_per == N/2) { ok = 1; for (auto it : st_s) cout << a[it] << " "; for (int i = dr_s.size() - 1; i >= 0; -- i ) cout << a[dr_s[i]] << " "; break; } } if (ok == 1) break; } 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...