#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool solve(vector<ll>v)
{
int l = 0 , r=v.size()-1;
if(v[l]==-1)
l++;
if(v[r]==-1)
r--;
ll newmid, mid=(v[l]+v[r])/2;
l++;
r--;
while(l<r)
{
if(v[l]==-1)
l++;
if(v[r]==-1)
r--;
newmid=(v[l]+v[r])>>1;
l++;
r--;
if(mid!=newmid)
return false;
}
return true;
}
int main()
{
ll n , k ;
cin >> n >> k;
//cout << n << " " << k << "\n";
vector<ll>v;
ll x , y;
for(int i = 0 ; i < n+k ; i++)
{
cin>> x;
v.push_back(x*2);
}
if(k==1)
{
for(int i = 0 ; i < n+k ; i++)
{
x=v[i];
v[i]=-1;
if(solve(v))
{
//cout << "yes\n";
break;
}
else v[i]=x;
//cout << "no\n";
}
for(int i = 0 ; i < n+k ; i++)
{
if(v[i]!=-1)
{
cout << v[i]/2 << " ";
}
}
return 0;
}
if(k==2)
{
for(int i = 0 ; i < n+k ; i++)
{
for(int j = i+1 ; j < n+k ; j++)
{
x=v[i];
v[i]=-1;
y=v[j];
v[j]=-1;
if(solve(v))
{
break;
}
else
{
v[i]=x;
v[j]=y;
}
}
}
for(int i = 0 ; i < n+k ; i++)
{
if(v[i]!=-1)
{
cout << v[i]/2 << " ";
}
}
return 0;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
364 KB |
Output is correct |
3 |
Correct |
3 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
169 ms |
968 KB |
Output is correct |
2 |
Correct |
86 ms |
4684 KB |
Output is correct |
3 |
Execution timed out |
3095 ms |
4336 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3057 ms |
3948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |