Submission #638665

#TimeUsernameProblemLanguageResultExecution timeMemory
638665Dec0DeddTable Tennis (info1cup20_tabletennis)C++14
87 / 100
3063 ms13160 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; const int N = 2e5+10; const int K = 50; int a[N], n, k, sz; gp_hash_table<int, bool> m; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n>>k; sz=n+k; for (int i=1; i<=sz; ++i) cin>>a[i]; for (int i=1; i<=sz; ++i) m[a[i]]=true; vector<int> x; bool ok=false; for (int i=1; i<=sz && !ok; ++i) { for (int j=sz; j>=sz-k+i-1 && !ok; --j) { int num=0, s=a[i]+a[j]; for (int k=1; k<=sz; ++k) { if (2*a[k] == s || m.find(s-a[k]) == m.end()) continue; ++num; } if (num >= n) { int p=0; for (int k=1; k<=sz; ++k) { if (2*a[k] == s || m.find(s-a[k]) == m.end()) continue; x.push_back(a[k]), x.push_back(s-a[k]); p+=2; if (p == n) break; } ok=true; break; } } } sort(x.begin(), x.end()); assert((int)x.size() == n); for (auto u : x) cout<<u<<" "; cout<<"\n"; }
#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...