Submission #1318289

#TimeUsernameProblemLanguageResultExecution timeMemory
1318289AzeTurk810Table Tennis (info1cup20_tabletennis)C++20
72 / 100
3094 ms31636 KiB
/* Telebe of Adicto && Mamedov yani AzeTurk810 I see humans but no humanity */ #include <algorithm> #include <cassert> #include <iostream> #include <map> #include <set> #include <vector> // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); using ll = long long; using namespace std; #define ln '\n' #define INFi 1e9 #define INFll 1e18 #define int ll #undef ONPC #ifdef ONPC #include <algo.hpp> #else #define dbg(...) #define dbg_out(...) #endif char solve() { int N, K; if (!(cin >> N >> K)) return 1; int M = N + K; vector<int> A(M); for (int i = 0; i < M; i++) cin >> A[i]; sort(A.begin(), A.end()); vector<int> sums; for (int i = 0; i <= K; i++) { for (int j = M - 1; j >= max(0LL, M - K - 2); --j) { sums.push_back(A[i] + A[j]); } } sort(sums.begin(), sums.end()); sums.erase(unique(sums.begin(), sums.end()), sums.end()); for (int sum : sums) { dbg(sum); map<int, int> cnt; multiset<int> mst; for (int i = 0; i < M; i++) { mst.insert(A[i]); int tar = sum - A[i]; if (cnt[tar] > 0) { cnt[tar]--; } else { cnt[A[i]]++; } } for (auto [num, cnt] : cnt) { dbg(cnt); dbg(num); dbg(mst); while (cnt > 0) { cnt--; assert(mst.find(num) != mst.end()); mst.erase(mst.find(num)); } } if (mst.size() >= N) { vector<int> ans; for (int i : mst) { ans.push_back(i); } int i = 0, j = ans.size() - 1; vector<int> res; while (i < j) { res.push_back(ans[i++]); res.push_back(ans[j--]); } sort(res.begin(), res.end()); for (int i = 0; i < N; i++) { cout << res[i] << ' '; } cout << ln; return 0; } } assert(0); return 0; } // Attack on titan<3 signed main() { ios::sync_with_stdio(0); cin.tie(nullptr); int t = 1e9; // cin >> t; for (int cases = 0; cases < t; cases++) { if (solve()) break; #ifdef ONPC cerr << "__________\n"; #endif } } // Just Imaginary /* ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⠀⠀⠀⢀⣴⣾⠀⠀⠀⡀⢀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣦⣾⣿⣿⣿⣿⣿⡆⠁⠀⢀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀⡠⠂⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠠⠔⠚⣿⣿⣿⣿⣿⣦⡄⠀⠁⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⢀⠠⠐⢂⠉⡀⣀⣤⣄⢻⣿⣿⡟⢈⡹⣿⡀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⡀⠄⠂⠈⠀⣶⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠘⣷⡀⠀⡀⠐⠂⠐⢄ ⠀⠀⠀⠀⠀⠀⠀⣿⣿⠟⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣀⣾⣷⠯⠀⠤⠤⠄⠈ ⠀⠀⠀⠀⠀⠀⣼⣿⡟⠀⠀⣹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⣰⣿⠋⠀⠀⢠⣾⣿⣿⣿⣿⣿⣭⠟⢻⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀ ⠀⠀⠀⣀⣶⡟⠁⠀⢾⣶⣿⠟⠉⠈⢻⣿⣿⣿⣦⣜⠀⠛⠛⠿⠁⠀⠀⠀⠀⠀ ⠚⠻⠿⠿⡿⠁⠀⢠⣿⣿⠁⠀⣠⠖⠋⠉⠻⣿⣿⣿⣶⡀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⣰⣿⡿⠃⠠⠊⠁⠀⠀⠀⠀⠈⢿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⢀⣴⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⣠⣾⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⢀⣴⠾⠟⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ */
#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...