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>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using namespace __gnu_cxx;
using namespace std;
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n , k;
cin >> n >> k;
vector < int > val(n + k);
for(auto &i : val)
cin >> i;
gp_hash_table < int , int > mp;
for(auto &i : val)
mp[i] = 1;
sort(all(val));
for(int i = 0; i <= k; ++i){
for(int j = sz(val) - 1; j >= sz(val) - k - 1; --j){
int alr = i + (sz(val) - 1 - j);
if(alr > k)
break;
int S = val[i] + val[j];
int tot = 1;
for(int p = i + 1; p < j; ++p){
if(S - val[p] <= val[p])
break;
if(!mp[S - val[p]]){
alr++;
if(alr > k)
break;
}else{
tot++;
}
}
if(tot == n / 2){
for(int p : val){
if((S-p) != p && mp[S - p])
cout << p << ' ';
}
cout << endl;
return 0;
}
}
}
assert(false);
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... |