错题001
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include<string>
#include<algorithm>
using namespace std;
long long h[100010], s[100010];
int main()
{
int t;
cin >> t;
for (int e = 0; e < t; e++)
{
long long n, sum1, sum2 = 0;
scanf("%lld%lld", &n, &sum1);
for (int i = 0; i < n; i++)
{
scanf("%lld", &h[i]);
s[i] = 0;
sum2 += h[i];
}
int num = sum1 - sum2;
int awa = 0;
for (int i = 0; i < n / 2; i++)
{
if (num >= n - 2 * i - 1 && num!=0)
{
s[i] = 1;
num -= n - 2 * i - 1;
}
if (num < n - 2 * i - 1)
continue;
}
if (num == 1)
awa = 1;
for (int i = 0; i <= n / 2 + 1; i++)
{
num = 0;
if (s[i] == 1)
for (int j = 0; j < n; j++)
{
if (h[j] == i + 1)
for (int w = 0; w < n; w++)
if (h[w] == n - i)
{
swap(h[j], h[w]);
num = 1;
break;
}
if (num == 1)
break;
}
}
num = 0;
if (awa == 1)
{
int flag = n;
for (int j = 0; j < n; j++)
{
if (h[j] == flag / 2 && s[flag / 2 - 1] != 1)
{
for (int w = 0; w < n; w++)
if (h[w] == flag / 2 + 1)
{
swap(h[j], h[w]);
num = 1;
break;
}
}
if (s[flag / 2 - 1] == 1)
flag -= 2;
if (num == 1)
break;
}
}
for (int i = 0; i < n; i++)
printf("%lld ", h[i]);
cout << endl;
}
return 0;
}