#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n,k;
cin>>n>>k;
ll N=n+k;
vector<ll>a(N);
for(ll i=0;i<N;i++)
{
cin>>a[i];
}
for(ll i=0;i<k+1;i++)
{
for(ll j=0;j+i<k+1;j++)
{
ll ile=1,co=a[i]+a[N-j-1];
vector<ll>b(n);
b[0]=a[i];
b[n-1]=a[N-j-1];
for(ll o=i+1;o<N-j-2;o++)
{
ll start=o+1,meta=N-j-2,s=(start+meta/2);
while(start<meta)
{
if(a[s]+a[o]==co)
{
break;
}
if(a[s]+a[o]>co)
{
meta=s;
}
if(a[s]+a[o]<co)
{
start=s+1;
}
s=(start+meta)/2;
}
if(a[s]+a[o]==co)
{
b[ile]=a[o];
b[n-1-ile]=a[s];
ile++;
}
if(ile==n/2)
{
break;
}
}
if(ile==n/2)
{
for(int w=0;w<n;w++)
{
cout<<b[w]<<" ";
}
cout<<endl;
return 0;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
504 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
856 KB |
Output is correct |
2 |
Runtime error |
18 ms |
6740 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
14 ms |
5208 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
5 ms |
344 KB |
Unexpected end of file - int32 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
8 ms |
344 KB |
Output not sorted |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
15 ms |
5236 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Runtime error |
15 ms |
6736 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |