Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

用数组把没有左边没有用的左括号记下来,然后每读入一个右括号就--。附代码哈

Posted by dakecaoxin at 2010-02-22 12:55:34 on Problem 1068
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator