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

Re:我的怎么老是超时???哪位大哥大姐帮帮看看!!!

Posted by tzj115 at 2007-08-01 21:52:34 on Problem 3183
In Reply To:我的怎么老是超时???哪位大哥大姐帮帮看看!!! Posted by:tzj115 at 2007-08-01 21:50:17
> # include <iostream.h>
> 
> int n;
> 
> int s[50010];
> int r[50010];
> 
> void des(int i)
> {
> 	if(i>0 && s[i-1]<s[i] && s[i-1]) 
> 		des(i-1);
> 	if(i<n-1 && s[i+1]<s[i] && s[i+1])
> 		des(i+1);
> 	s[i]=-1;
> }
> 
> int first()
> {
> 	int f;
> 	int i=0;
>     while(s[i]==-1 && i<n)
> 		++i;
> 	if(i>=n)
> 		return -10;
> 	while(s[i]<s[i+1] && i+1<n)
> 		++i;
> 	return i;
> }
> 
> int main()
> {
> 	int t=0;
> 	int wei;
> 
> 	cin>>n;
> 	while(t<n)
> 	{
> 		cin>>s[t++];
> 	}
> 	t=0;
> 	wei=first();
> 	while(wei>=0)
> 	{
> 		r[t++]=wei+1;
> 		des(wei);
> 		wei=first();
> 	}
> 	for(int k=0;k<t;k++)
> 		cout<<r[k]<<"\n";
> 	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