#include <iostream>
#include <algorithm>
using namespace std;
#define MAXN 150000
#define MAXK 400
int v[MAXN+MAXK+1];
int sol[MAXN+1];
int main()
{
int n, k;
cin>>n>>k;
int i;
long long sum;
sum=0;
for(i=1; i<=n+k; i++)
{
cin>>v[i];
sum+=v[i];
}
int p, ok, csum, j;
if(k==1)
{
int p, csum, ok, j;
for(i=1; i<=n+k; i++)
{
if((sum-v[i])%(n/2)==0)
{
p=1;
for(j=1; j<=n+k; j++)
if(j!=i)
sol[p++]=v[j];
p=n;
csum=(sum-v[i])/(n/2);
ok=0;
for(j=1; j<=n/2; j++)
{
if(sol[j]+sol[p]==csum)
ok++;
p--;
}
if(ok==n/2)
break;
}
}
}
else if(n<100)
{
do
{
p=1;
for(j=1; j<=n; j++)
sol[p++]=v[j];
p=n;
csum=sol[j]+sol[p];
p--;
ok=1;
for(j=2; j<=n/2; j++)
{
if(sol[j]+sol[p]==csum)
ok++;
p--;
}
if(ok==n/2)
break;
}
while(next_permutation(v+1, v+n+k+1));
}
for(i=1; i<=n; i++)
cout<<sol[i]<<" ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
600 KB |
Output is correct |
2 |
Correct |
81 ms |
4420 KB |
Output is correct |
3 |
Correct |
70 ms |
4436 KB |
Output is correct |
4 |
Correct |
54 ms |
4432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
48 ms |
1148 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3029 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3097 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3014 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3062 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3010 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |