제출 #638670

#제출 시각아이디문제언어결과실행 시간메모리
638670Dec0DeddTable Tennis (info1cup20_tabletennis)C++14
24 / 100
38 ms14448 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 num(int s) { int res=0; for (int i=1; i<=sz; ++i) { if (2*a[i] == s || m.find(s-a[i]) == m.end()) continue; ++res; } return res; } vector<int> gen(int s) { vector<int> res; int p=0; for (int i=1; i<=sz; ++i) { if (2*a[i] == s || m.find(s-a[i]) == m.end()) continue; res.push_back(a[i]), res.push_back(s-a[i]); p+=2; if (p == n) break; } return res; } 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; if (sz <= 4*K) { bool ok=false; for (int i=1; i<=sz && !ok; ++i) { for (int j=sz; j>=sz-k+i-1 && !ok; --j) { if (num(a[i]+a[j]) >= n) { x=gen(a[i]+a[j]); ok=true; break; } } } } else { gp_hash_table<int, int> cnt; for (int i=1; i<=k; ++i) { for (int j=n; j<=sz; ++j) ++cnt[a[i]+a[j]]; } for (auto u : cnt) { if (u.second == k) { if (num(u.first) >= n) { x=gen(u.first); 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...