이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |