poj2833

//poj2833优先队列。数据量太大,而且没有必要全部排序。

//优先队列
//*
#include<iterator>
#include <stdio.h>
#include <queue>
#include<algorithm>
#include<iterator>
using namespace std;
int main(){
	long n1,n2;
	long n,t;		
	priority_queue<long> minQ;
		priority_queue<long,vector<long>,greater<long> > maxQ;
	while(scanf("%ld%ld%ld",&n1,&n2,&n)){
		if(n==0&&n1==0&&n2==0) break;

		long long sum=0;
		for(int i=0;i<n;i++){
			scanf("%ld",&t);
			sum+=t;
			minQ.push(t);
			maxQ.push(t);
			if(minQ.size()>n2) minQ.pop();
			if(maxQ.size()>n1) maxQ.pop();
		}
		while(!minQ.empty()) {sum-=minQ.top();minQ.pop();}
		while(!maxQ.empty()) {sum-=maxQ.top();maxQ.pop();}
		printf("%.6f\n",1.0*(sum)/(n-n1-n2));
	}
	return 0;
}
//*/

  

posted @ 2015-04-19 23:55  PaigeWw  阅读(215)  评论(0编辑  收藏  举报