http://acm.hdu.edu.cn/showproblem.php?pid=1557
#include <iostream>
#include <cstring>
using namespace std;
int a[25];
int ans[25];
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
int sum = 0;
for (int i = 0; i < n; i++)
{
cin >> a[i];
sum += a[i];
}
memset(ans, 0, sizeof(ans));
for (int i = 0; i < (1 << n); i++)
{
int s = 0;
for (int j = 0; j < n; j++)
{
if (i & (1 << j))
{
s += a[j];
}
}
if (s * 2 <= sum)
{
continue;
}
for (int j = 0; j < n; j++)
{
if (i & (1 << j))
{
if ((s - a[j]) * 2 <= sum)
{
ans[j]++;
}
}
}
}
for (int i = 0; i < n; i++)
{
if (i != n - 1)
{
cout << ans[i] << " ";
}
else
{
cout << ans[i] << endl;
}
}
}
return 0;
}