Submission #675121

#TimeUsernameProblemLanguageResultExecution timeMemory
675121hollwo_pelwTable Tennis (info1cup20_tabletennis)C++17
0 / 100
96 ms5788 KiB
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/trie_policy.hpp> // #include <ext/rope> using namespace std; // using namespace __gnu_cxx; // using namespace __gnu_pbds; void Hollwo_Pelw(); signed main(){ #ifndef hollwo_pelw_local if (fopen(".inp", "r")) assert(freopen(".inp", "r", stdin)), assert(freopen(".out", "w", stdout)); #else using namespace chrono; auto start = steady_clock::now(); #endif cin.tie(0), cout.tie(0) -> sync_with_stdio(0); int testcases = 1; // cin >> testcases; for (int test = 1; test <= testcases; test++){ // cout << "Case #" << test << ": "; Hollwo_Pelw(); } #ifdef hollwo_pelw_local auto end = steady_clock::now(); cout << "\nExecution time : " << duration_cast<milliseconds> (end - start).count() << "[ms]" << endl; #endif } const int N = 2e5; int n, k, a[N]; bool check(int sum) { int cnt = 0; vector<int> l, r; for (int i = 1, j = n; i < j; i++) { while (j > i && a[j] + a[i] > sum) j --; if (j > i && a[j] + a[i] == sum) { cnt ++; l.push_back(a[i]); r.push_back(a[j]); } } if (cnt == n / 2) { reverse(r.begin(), r.end()); for (int i : l) cout << i << ' '; for (int i : r) cout << i << ' '; } return cnt == n / 2; } void Hollwo_Pelw(){ cin >> n >> k; for (int i = 1; i <= n + k; i++) cin >> a[i]; map<int, int> cnt; if (4 * k > n) { for (int i = 1; i <= n + k; i++) for (int j = i + 1; j <= n + k; j++) cnt[a[i] + a[j]] ++; for (auto [v, c] : cnt) { if (c >= n / 2) if (check(c)) return; } } for (int i = 1; i <= 2 * k; i++) { for (int j = n - k + 1; j <= n + k; j++) { cnt[a[i] + a[j]] ++; } } for (auto [v, c] : cnt) { if (c >= k) if (check(c)) return; } }
#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...