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

同一段代码,前些天TLE,今天一交就AC了,也不知道是怎么回事,发现一个书写错误

Posted by ecjtubaowp at 2007-02-06 16:46:26 on Problem 2967
#include <stdio.h>
#include<stdlib.h>e
                  ~~
#include<algorithm>
using namespace std;
int comp(const void* a,const void *b) 
{ 
	return *(unsigned int*)a-*(unsigned int*)b; 
}
unsigned int a[1000010];
int main()
{int i;
	int n,flag1,flag2;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		sort(a,a+n);
   // qsort(a,n,sizeof(unsigned int),comp); 
    flag1=0,flag2=0;
		if(a[0]+a[1]<=a[n-1])
		{
			flag1=1;
		}
	for(i=2;i<n;i++)
		{
			if(a[i-1]+a[i-2]>a[i])
			{
				flag2=1;
				break;
			}
		}
		if(flag1==1&&flag2==1)
		{
			printf("The set is accepted.\n");
		}
		else
		{
			printf("The set is rejected.\n");
		}
	}
}


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