poj2833

来源:互联网 发布:免费听英语的软件 编辑:程序博客网 时间:2024/05/19 02:30
//============================================================================// Name        : 2833.cpp// Author      : // Version     :// Copyright   : Your copyright notice// Description : Hello World in C++, Ansi-style//============================================================================#include <stdio.h>#include <queue>using namespace std;priority_queue<int, vector<int>, greater<int> > qbig;priority_queue<int> qsmall;int main() {int n1, n2, n;while (1) {scanf("%d %d %d", &n1, &n2, &n);if (n == 0) {break;}int data;long long sum = 0;for (int i = 0; i < n; i++) {scanf("%d", &data);sum += data;if (i < n1) {qbig.push(data);} else {if (qbig.top() < data) {qbig.push(data);qbig.pop();}}if (i < n2) {qsmall.push(data);} else {if (qsmall.top() > data) {qsmall.push(data);qsmall.pop();}}}while (!qbig.empty()) {sum -= qbig.top();qbig.pop();}while (!qsmall.empty()) {sum -= qsmall.top();qsmall.pop();}double count = n - n1 - n2;printf("%.6f\n", sum / count);}return 0;}

原创粉丝点击