이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
const int N=1e5;
const int off=(1<<20);
const int MOD = 1e9+7;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,k;
cin >> n >> k;
int sz=n+k;
int a[sz];
unordered_map<int,bool>mp;
for(int i=0;i<sz;i++){
cin >>a[i];
mp[a[i]]=1;
}
// sort(a,a+sz);
for(int i=0;i<=k;i++){
for(int j=0;j<=k-i;j++){
int ans=a[i]+a[sz-j-1];
int cur=i+j;
vector<int>v;
for(int w=i;w<=sz-j-1;w++){
if(a[w]!=ans-a[w]){
if(!mp[ans-a[w]]){
if(cur<k&&cur>=0)cur++;
else cur=-1;
}
else v.pb(a[w]);
}
else{
if(cur<k&&cur>=0)cur++;
else cur=-1;
}
if(cur==-1)break;
}
if(cur==k){
for(auto it:v){
cout<<it<<' ';
}
return 0;
}
// cout<<v.back()<<' ';
}
}
// cout<<v.size()<<endl;
}
/*
*/
# | 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... |