Test instructions: Pasha has 2n cups, each cup has a different volume. Pasha has 2n friends, men and women each n. Now pasha to the total volume W of tea poured in 2n cups, to the 2n friends, and the same sex Friends Cup tea volume is the same, and each male friend Cup tea volume is each female friends cup of tea twice times the volume. The maximum value of the sum of the tea volume in all friends ' cups.
water problem. First, according to the volume of the Cup, the smaller of the N Cup must be given to the girls, the larger n cups to the boys. If not, if a male friend Cup volume than a female friend Cup volume is small, because the male Friends cup tea volume is larger, then exchange their cups, can still be able to load their original tea. So it seems that this sort of method can be. So since each same-sex friend's tea as much, we only need to consider the male friends of the cup volume is the smallest and female friends of the smallest cup volume can be. Female friends with the smallest cup volume of x, male Friends Total cup volume is the smallest of Y, because the total amount of tea only W, so the final answer is min (min (2x,y) *1.5*n,w).
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <string > #include <algorithm> #include <stack> #include <queue> #include <vector> #include <map > #include <set>using namespace std;const int MAX = 100005;int n;double W, a[2*max];void input () {for (int i = 0; i < 2*n; i++) scanf ("%lf", &a[i]);} void Solve () { sort (A, a + 2*n); printf ("%.6lf\n", Min (min (2*a[0], a[n]) *1.5*n, W));} int main () {while (scanf ("%d%lf", &n, &w)! = EOF) { input (); Solve (); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Codeforces 557B Pasha and Tea pour