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;
int n, k;
int a[150401];
void gen(int x){
vector<int> Fr, Ba;
int l = 0, r = n + k - 1;
while(l < r){
if(a[l] + a[r] == x) { Fr.push_back(l); Ba.push_back(r); l++; r--; }
else if(a[l] + a[r] > x) r--;
else l++;
}
reverse(Ba.begin(), Ba.end());
for(auto i : Fr) cout << a[i] << ' ';
for(auto i : Ba) cout << a[i] << ' ';
}
unordered_map<int, int> M;
int main(){
cin.tie(0); cout.tie(0)->sync_with_stdio(false);
cin >> n >> k;
for(int i = 0; i < n + k; i++){
cin >> a[i];
}
vector<int> v;
for(int i = 0; i <= k; i++){
for(int j = max(i + 1, n + k - 1 - i - k); j <= min(n + k - 1, n + k - 1 - i + k); j++){
M[a[i] + a[j]]++;
}
}
for(int i = k + 1; i < n + k; i++){
for(int j = max(i + 1, n + k - 1 - i - k); j <= min(n + k - 1, n + k - 1 - i + k); j++){
if(M.count(a[i] + a[j])) M[a[i] + a[j]]++;
}
}
for(auto m : M){
if(m.second == n / 2){
gen(m.first);
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... |