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??

Posted by sail6 at 2006-08-21 11:00:34 on Problem 2833
#include<stdio.h>
#include<stdlib.h>
#include<iostream.h>
//#include <algorithm>
//using namespace std;

//int a[5000000];

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

int main()
{
	int n1,n2,n;
	int a[25];
	while(scanf("%d%d%d",&n1,&n2,&n))
	{
		if(n1==0&&n2==0&&n==0)
		{
			break;
		}
		int i;
		//int c=0;
		long  sum=0;
		
		
		for(i=0;i<=n1+n2;i++)
		{
			scanf("%d",&a[i]);
			
		}
		qsort(a,n1+n2+1,sizeof(int),comp); 
	//	for(i=0;i<=n1+n2;i++)
	//	{
		//	printf("%d\n",a[i]);
		//}
		//cout<<a[n2]<<endl;
		sum+=a[n2];
		
		
		for(i=n1+n2+1;i<n;i++)
		{
			
			scanf("%d",&a[n2]);
			//	sort(0,n1+n2-1);
		   qsort(a,n1+n2+1,sizeof(int),comp); 
		//	for(i=0;i<=n1+n2;i++)
		//	{
			//	printf("%d   ",a[i]);
		//	}
			
			sum+=a[n2];
			
			
		}
	//	cout<<sum<<endl;
	
			

		
		
		
		
		double ave=sum/(n-n1-n2);
		printf("%.6lf\n",ave);
		
		
		//cout<<sum<<endl;
		//printf("%d\n",sum);
		
		
	}
	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