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

Memory Limit Exceed?????????????????

Posted by y05zh at 2006-08-20 17:21:59 on Problem 2833
#include<stdio.h>
#include<stdlib.h>
#include<iostream.h>

int a[5000000];

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

int main()
{
	int n1,n2,n;
	while(scanf("%d%d%d",&n1,&n2,&n))
	{
		if(n1==0&&n2==0&&n==0)
		{
			break;
		}
		int i;
		
		for( i = 0 ; i < n;i++)
		{
			scanf("%d",&a[i]);
		}
		qsort(a,n,sizeof(int),comp); 
		
		
		double  sum=0;
		for(i=n2;i<n-n1;i++)
		{
			//cout<<a[i]<<endl;
			sum+=a[i];
		}
		//cout<<sum<<endl;
		//printf("%d\n",sum);
		double ave=sum/(n-n1-n2);
		printf("%.6lf\n",ave);
		
		
	}
	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