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 wanpi0user at 2006-06-26 21:00:01 on Problem 2833
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<iostream>
#include<fstream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;
int  arr[5000005];
struct greaterthan
{	
	bool operator()(const int& _Left, const int& _Right) const
	{	
		return (_Left > _Right);
	}
};

struct lessthan
{	
	bool operator()(const int& _Left, const int& _Right) const
	{	
		return (_Left < _Right);
	}
};

int main()
{
	int num, low, high, avr, n, ii;
	__int64 total;
	while(true)
	{
		scanf("%d%d%d",&low,&high, &num);
		if((low == 0) && (high == 0) && (num == 0)) break;
		for(ii = 0; ii < num; ii++)
		{
			scanf("%d",arr + ii);
		}
		nth_element(arr + 0  , arr + low,  arr + num, greaterthan());
		nth_element(arr + low, arr + high, arr + num, lessthan());
		for(ii = low + high, total = 0L;ii < num; ii++)
		{
			total += arr[ii];
		}
		printf("%.6lf\n",(double)(total)/(double)(num - low - high));
	}
	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