이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O3")
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,ull>pairull;
typedef pair<ll,pairll>pair3l;
typedef long double ld;
typedef pair<ld,ll>pairld;
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define N 100007
//#define MOD 998244353
#define INF 100000000000007
#define eps 0.0000000001
ll n,k,d[2*N],s[2*N];
ll S(ll x){
ll res=0;
for(int i=1;i<=n+k;i++){
s[i]=0;
}
ll l=1;
ll r=n+k;
while(l<r){
if(d[l]+d[r]<x)l++;
else if(d[l]+d[r]>x)r--;
else{
res+=2;
s[l]=1;
s[r]=1;
l++;
r--;
}
if(res==n)return 1;
}
return 0;
}
int main(){
cin>>n>>k;
for(int i=1;i<=n+k;i++){
cin>>d[i];
}
sort(d+1,d+1+n+k);
ll fl=0;
for(int i=1;i<=n+k;i++){
for(int j=n+k;j>i;j--){
if(j-i+1>=n){
if(S(d[i]+d[j])==1){
fl=1;
break;
}
}else break;
}
if(fl==1)break;
}
//if(fl==0)exit(1);
ll r=n;
for(int i=1;i<=n+k;i++){
if(s[i]==1){
cout<<d[i];
r--;
if(r!=0)cout<<" ";
}
}
//if(r!=0)exit(1);
//cout<<endl;
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... |