模拟。
#include<iostream>
#include<string>
using namespace std;
int t;
int n;
int P[25];
int W[25];
string s;
int main()
{
scanf("%d", &t);
for(int i = 0; i < t; i ++)
{
s = "";
scanf("%d", &n);
for(int j = 0; j < n; j ++)
scanf("%d", &P[j]);
for(int j = 0; j < n; j ++)
{
for(int k = 0; k < (j == 0 ? P[0] : P[j] - P[j - 1]); k ++)
s += '(';
s += ')';
}
int count1 = 0, count2 = 0, tmp = 0, k;
for(int j = 0; j < s.size(); j ++)
if(s[j] == ')')
{
k = j - 1;
tmp = 1;
count2 = 1;
while(tmp != 0)
{
if(s[k] == ')')
{
tmp ++;
count2 ++;
}
else
tmp --;
k --;
}
W[count1] = count2;
count1 ++;
}
for(int j = 0; j < n; j ++)
{
printf("%d", W[j]);
if(j == n - 1)
printf("\n");
else
printf(" ");
}
}
// system("pause");
return 0;
}