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

为什么WA????????

Posted by HebtuSb04 at 2006-08-17 17:37:17 on Problem 2967
#include <stdio.h>
#include<stdlib.h>


int comp(const void* a,const void *b) 
{ 
	return *(unsigned int*)a-*(unsigned int*)b; 
}


unsigned int a[1000010];

int main()
{
	
	//	char s[3][100];
	int i;
	int n;
	while(scanf("%d",&n))
	{
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
	//	sort(a, a+n);
		qsort(a,n,sizeof(unsigned int),comp); 
		/*for(i=0;i<n;i++)
		{
			cout<<a[i]<<endl;
		}
		*/
		int 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");
		}
	}
	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