| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
用数组把没有左边没有用的左括号记下来,然后每读入一个右括号就--。附代码哈
#include <iostream>
using namespace std;
int p[25];
int h[25];
int main()
{
int t,n,i,j;
int c,num;
cin>>t;
while(t--){
cin>>n;
for(i=1;i<=n;i++)
cin>>p[i];
h[1]=p[1]-1;cout<<1<<' ';
for(i=2;i<=n;i++){
h[i]=p[i]-p[i-1];
num=1;
for(j=i;j>=2;j--,num++){
if(h[j]>0){
h[j]--;
break;
}
}cout<<num<<' ';
}cout<<endl;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator