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 tcxgsy at 2006-08-14 15:59:36 on Problem 2967
#include "stdio.h"
#include "iostream.h"
#define N 10000002

long qui_sort(long *a,long st,long en)
{
     long temp;
	temp=a[st];
	while(st<en)
	{
		for(;st<en;en--)
			if(a[en]<temp)
			{
				a[st]=a[en];
				st++;
				break;			
			}
	     for(;st<en;st++)
			 if(a[st]>=temp)
			 {
				 a[en]=a[st];
				 en--;
				 break;		 
			 }
	}
    a[st]=temp;
	return st;
}
long * fun_sort(long *a,long st,long en)
{
	long m;
	if(en-st>=1)
	{
		m=qui_sort(a,st,en);
		fun_sort(a,st,m-1);
		fun_sort(a,m+1,en);
	}
	return a;
}
int main()
{
	long s[N],*c,m,i;
	long Test;
	bool cm;

	cin>>Test;
	for(i=1;i<=Test;i++)
		cin>>s[i];
	
	c=fun_sort(s,1,Test);

   cm=false;
     if(s[1]+s[2]>s[Test])
	 {
	     cm=true;
		 cout<<"The set is rejected."<<endl;
		 return 1;
	 }
    for( long j=1;j<=Test-2;j++)
	{
		if(s[j]+s[j+1]>s[j+2])
		     cm=true;
		 if(cm==true) break;
	}
	   if(cm==true) cout<<"The set is accepted."<<endl;
	   else cout<<"The set is rejected."<<endl;
 return 1;

}


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