이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define read freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)
const ll N=1e6+10,M=505,OO=1e16,mod=1e9+7;
int n,k;
ll a[N];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
unordered_map<ll,int>cnt;
for(int i=0;i<n+k;++i){
cin>>a[i];
cnt[a[i]]++;
}
vector<ll>ans;
for(int i=0;i<=k;++i){
for(int j=n+k-1;j>=n-1;--j){
ll sum=a[i]+a[j];
int pairs=0;
vector<ll>cur;
for(int l=0;l<n+k;++l){
if(cnt[sum-a[l]]&&sum-a[l]>a[l]){
cur.push_back(a[l]);
cur.push_back(sum-a[l]);
++pairs;
}
if(pairs==n/2){
ans=cur;
break;
}
}
if(!ans.empty()) break;
}
if(!ans.empty()) break;
}
sort(ans.begin(),ans.end());
for(ll i:ans) cout<<i<<' ';
cout<<"\n";
}
# | 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... |