이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll MAXN=1e5+5e4+10;
const ll MAXK=4e2+10;
const ll MAXA=1e9+10;
ll a[MAXN+MAXK],n,k,m;
vector<ll>ans;
void read()
{
cin>>n>>k;
m=n+k;
for(ll i=1;i<=m;i++)
cin>>a[i];
}
void print()
{
sort(ans.begin(), ans.end());
ll sz=ans.size();
for(ll i=0;i<sz;i++)
{
cout<<ans[i]<<" ";
}
cout<<endl;
}
void solve()
{
for(ll i=n/2;i<=n/2+k+1;i++)
{
ll cur=a[i]+a[i+1];
ll left=1,right=n+k;
ll cnt=0;
ans.clear();
while(left<right&&cnt<n/2)
{
///cout<<"Lqwa granica : "<<left<<endl;
while(left<right&&a[left]+a[right]>cur)
{
right--;
///cout<<"Dqsna granica : "<<right<<endl;
}
if(left<right&&a[left]+a[right]==cur)
{
ans.push_back(a[left]);
ans.push_back(a[right]);
///cout<<"Nowo dobawqne na "<<left<<" i "<<right<<endl;
cnt++;
}
left++;
}
if(cnt==n/2)
{
print();
return;
}
}
}
int main()
{
#ifdef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
read();
solve();
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... |