#include <iostream.h>
int main()
{
int i,t,n,j,k;
int a[40],b[20];
int c[40];
cin>>t;
for(k=0;k<t;k++)
{
int pre;
int pos=0;
cin>>n;
for(j=0;j<n;j++)
cin>>b[j];
pre=0;
for(j=0;j<n;j++)
{
for(i=0;i<b[j]-pre;i++)
{
a[pos]=0;
pos++;
}
a[pos]=1;
pos++;
pre=b[j];
}
int pos1=0,pos2;
int flag=0;
for(i=0;i<n;i++)
c[i]=1;
for(j=0;j<n;j++)
{
while(flag==0)
{
if(c[pos1]==1 && a[pos1]==0)
{
pos2=pos1+1;
while(c[pos2]==0)
pos2++;
if(a[pos2]==1)
flag=1;
}
pos1++;
}
c[pos1]=c[pos2]=0;
int sum=0;
for(i=pos1;i<=pos2;i++)
if(a[i]==1)
sum++;
cout<<sum<<" ";
}
// for(i=0;i<2*n;i++)
//cout<<a[i];
cout<<endl;
}
}
正文
jnu(Parencodings)2005-08-21 16:20:00
【评论】 【打印】 【字体:大 中 小】 本文链接:http://blog.pfan.cn/elva6401/3998.html
阅读(2843) | 评论(1)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论