제출 #675083

#제출 시각아이디문제언어결과실행 시간메모리
675083uyluluTable Tennis (info1cup20_tabletennis)C++17
9 / 100
3087 ms127508 KiB
#include <bits/stdc++.h> using namespace std; #define ld long double #define int long long #define endl "\n" const int N = 3e5,K = 400; int num[N + 1],n,k; map<int,int> mp; void build(int sum) { vector<pair<int,int>> asd; mp.clear(); for(int i = 1;i <= n;i++) { mp[num[i]] = 1; } for(int i = 1;i <= n;i++) { if(sum < num[i]) continue; if(mp[sum - num[i]]) { asd.push_back({sum - num[i],num[i]}); } } vector<int> res; for(int i = 0;i < n/2;i++) { res.push_back(asd[i].first); res.push_back(asd[i].second); } sort(res.begin(),res.end()); for(auto u : res) { cout<<u<<" "; } return; } signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); cin>>n>>k; for(int i = 1;i <= n + k;i++) { cin>>num[i]; } sort(num + 1,num + 1 + n + k); int len = n + k; for(int i = 1;i <= len;i++) { int ptr = len - i + 1; while(ptr <= len && abs(i - 1 - (len - ptr)) <= k) { mp[num[i] + num[ptr]]++; ptr++; } ptr = len - i + 1; while(ptr > i && abs(i - 1 - (len - ptr)) <= k) { mp[num[i] + num[ptr]]++; ptr--; } } int res = -1; for(auto u : mp) { if(u.second >= n/2) { res = u.first; break; } } build(res); 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...