이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ff first
#define ss second
#define ll long long
using namespace std;
const int MAX=2e5+5;
const ll INF=1e10;
int A[MAX];
int n;
unordered_map<int,int>m;
vector<int>v;
bool res(int suma){
int ans=0;
for(int i=0;i<n;i++){
if(!m[A[i]] or ans==n/2) continue;
if(A[i]>suma) continue;
if(m[suma-A[i]]){
m[suma-A[i]]--;
m[A[i]]--;
ans++;
v.push_back(A[i]);
v.push_back(suma-A[i]);
}
}
if(ans==n/2) return true;
else return false;
}
void go(){
int k; cin>>n>>k;
for(int i=0;i<(n+k);i++){
cin>>A[i];
m[A[i]]++;
}
sort(A,A+n);
for(int i=0;i<=k;i++){
for(int j=0;j<=k;j++){
int suma=A[i]+A[n-1-j];
if(res(suma)){
sort(v.begin(),v.end());
for(auto it:v) cout<<it<<" ";
break;
}
else v.clear();
}
}
}
int main(){
fastio;
go();
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... |