This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 + k;i++) {
mp[num[i]] = 1;
}
for(int i = 1;i <= n + k;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];
}
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;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |