557B.md (2230B)
1 Source: https://codeforces.com/problemset/problem/557/B 2 3 B. Pasha and Tea 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Pasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of *w* milliliters and 2*n* tea cups, each cup is for one of Pasha's friends. The *i*-th cup can hold at most *a**i* milliliters of water. 22 23 It turned out that among Pasha's friends there are exactly *n* boys and exactly *n* girls and all of them are going to come to the tea party. To please everyone, Pasha decided to pour the water for the tea as follows: 24 25 * Pasha can boil the teapot exactly once by pouring there at most *w* milliliters of water; 26 * Pasha pours the same amount of water to each girl; 27 * Pasha pours the same amount of water to each boy; 28 * if each girl gets *x* milliliters of water, then each boy gets 2*x* milliliters of water. 29 30 In the other words, each boy should get two times more water than each girl does. 31 32 Pasha is very kind and polite, so he wants to maximize the total amount of the water that he pours to his friends. Your task is to help him and determine the optimum distribution of cups between Pasha's friends. 33 34 Input 35 36 The first line of the input contains two integers, *n* and *w* (1 ≤ *n* ≤ 105, 1 ≤ *w* ≤ 109) — the number of Pasha's friends that are boys (equal to the number of Pasha's friends that are girls) and the capacity of Pasha's teapot in milliliters. 37 38 The second line of the input contains the sequence of integers *a**i* (1 ≤ *a**i* ≤ 109, 1 ≤ *i* ≤ 2*n*) — the capacities of Pasha's tea cups in milliliters. 39 40 Output 41 42 Print a single real number — the maximum total amount of water in milliliters that Pasha can pour to his friends without violating the given conditions. Your answer will be considered correct if its absolute or relative error doesn't exceed 10- 6. 43 44 Examples 45 46 Input 47 48 ``` 49 2 4 50 1 1 1 1 51 ``` 52 53 Output 54 55 ``` 56 3 57 ``` 58 59 Input 60 61 ``` 62 3 18 63 4 4 4 2 2 2 64 ``` 65 66 Output 67 68 ``` 69 18 70 ``` 71 72 Input 73 74 ``` 75 1 5 76 2 3 77 ``` 78 79 Output 80 81 ``` 82 4.5 83 ``` 84 85 Note 86 87 Pasha also has candies that he is going to give to girls but that is another task...