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 ricerice at 2007-10-31 23:56:57
#include<iostream.h>

const int m=1010;  //序列长度

int sort(int a[],int n)
{
	int s[m],i,j,k,t,max=0,temi=0,temj=0;

	for(i=0;i<n;i++)
		if(a[i]>temi)
		{
			temi=a[i];
			temj=a[i];
		}

	for(i=0;i<n-1;i++)
	{
		if(a[i]<temi)  
		{              
			temi=a[i];k=i;t=1;
			while(t>0)
			{
				t=0;s[t]=a[i];
				for(j=k+1;j<n;j++)
				{
					if(s[t]<a[j])
					{
						s[++t]=a[j];
						if(t==1)
							if(s[1]<temj)          
							{                      
								temj=s[1];k=j;     
							}
							else              
							{                 
								t--;
								continue;
							}
					}
				}//for
				if(t>max)
					max=t;
			}//while
		}//if
	}//for

	return max+1;
}

int main(void)
{
	int a[m],n;
	cin>>n;
    for(int i=0;i<n;i++)
		cin>>a[i];
	cout<<sort(a,n)<<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