#include<bits/stdc++.h>
using namespace std;
using pll = pair<int,int>;
int c[200017];
void luck()
{
int n;
cin >> n;
vector<pll>v(n);
int cnt=0;
for (auto& [x, y] : v)
{
cin >> x;
y = ++cnt;
}
sort(v.begin(), v.end(), greater<pll>());
int len = 1;
int f = 1;
long long int sum = 0;
cnt = 0;
for (auto [x,y]:v)
{
cnt++;
sum = sum + ((long long)len * x);
c[y] = len * f;
f *= -1;
if (cnt % 2 == 0)
len++;
}
cout << 2 * sum << endl;
cout << 0 << " ";
for (int i = 1; i <= n; i++)
{
cout << c[i] << " ";
}
}
int main()
{
int T;
cin >> T;
while (T--)
{
luck();
}
return 0;
}
Codeforces Round #757 (Div. 2)
最新推荐文章于 2022-01-13 14:38:08 发布