302874: CF557B. Pasha and Tea

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Pasha and Tea

题意翻译

题目描述:\ Pasha决定去邀请他的朋友参加茶会。在那样的场合中,他有一个容量为w毫升的茶壶和2n2个茶杯。每个茶杯都是为Pasha的一个朋友准备的。第iii个茶杯可以装下ai毫升的水。\ 结果,在Pasha的朋友之中,有n个男孩和n个女孩,并且他们都会来到茶会。为了让每个人都满意,Pasha决定按照如下的方法来为茶倒水: - Pasha可以通过向茶壶中倒入w毫升的水来把水一次烧开; - Pasha给每个男孩入相同体积的茶水; - Pasha给每个女孩入相同体积的茶水; - 如果每个女孩能得到x毫升的水,那么每个男孩可以得到2x毫升的水。换言之,每个男孩应该得到的茶水是每个女孩的两倍。 - Pasha非常和蔼礼貌,所以他想使他倒给朋友的茶水的总量最大。你的任务是帮助他决定给Pasha的每个朋友倒水的最佳方案。 输入格式:\ 输入文件的第一行包含两个整数n和w(1<=n<=10^5,1<=w<=10^9)——n代表Pasha的朋友中男孩子的人数(和女孩子的人数相等),w代表Pasha的茶壶的容量。(单位:毫升)\ 输入文件的第二行是一系列的数字ai (1<=ai<=10^9,1<=i<=2n)——代表Pasha的每个茶杯的容量。 \ \ 输出格式:\ 只需输出一个实数——不违背上述规则的情况下Pasha能倒给他的朋友的水的最大体积(单位:毫升)。如果你的答案和标准答案之间的误差小于10^-6将会被认为是正确的。 \ \ 提示\ Pasha其实还准备了一些准备给女孩子们的糖果,但那是另一回事了……qwq

题目描述

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 $ 2n $ tea cups, each cup is for one of Pasha's friends. The $ i $ -th cup can hold at most $ a_{i} $ milliliters of water. 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: - Pasha can boil the teapot exactly once by pouring there at most $ w $ milliliters of water; - Pasha pours the same amount of water to each girl; - Pasha pours the same amount of water to each boy; - if each girl gets $ x $ milliliters of water, then each boy gets $ 2x $ milliliters of water. In the other words, each boy should get two times more water than each girl does. 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.

输入输出格式

输入格式


The first line of the input contains two integers, $ n $ and $ w $ ( $ 1<=n<=10^{5} $ , $ 1<=w<=10^{9} $ ) — 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. The second line of the input contains the sequence of integers $ a_{i} $ ( $ 1<=a_{i}<=10^{9} $ , $ 1<=i<=2n $ ) — the capacities of Pasha's tea cups in milliliters.

输出格式


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} $ .

输入输出样例

输入样例 #1

2 4
1 1 1 1

输出样例 #1

3

输入样例 #2

3 18
4 4 4 2 2 2

输出样例 #2

18

输入样例 #3

1 5
2 3

输出样例 #3

4.5

说明

Pasha also has candies that he is going to give to girls but that is another task...

Input

题意翻译

题目描述:\ Pasha决定去邀请他的朋友参加茶会。在那样的场合中,他有一个容量为w毫升的茶壶和2n2个茶杯。每个茶杯都是为Pasha的一个朋友准备的。第iii个茶杯可以装下ai毫升的水。\ 结果,在Pasha的朋友之中,有n个男孩和n个女孩,并且他们都会来到茶会。为了让每个人都满意,Pasha决定按照如下的方法来为茶倒水: - Pasha可以通过向茶壶中倒入w毫升的水来把水一次烧开; - Pasha给每个男孩入相同体积的茶水; - Pasha给每个女孩入相同体积的茶水; - 如果每个女孩能得到x毫升的水,那么每个男孩可以得到2x毫升的水。换言之,每个男孩应该得到的茶水是每个女孩的两倍。 - Pasha非常和蔼礼貌,所以他想使他倒给朋友的茶水的总量最大。你的任务是帮助他决定给Pasha的每个朋友倒水的最佳方案。 输入格式:\ 输入文件的第一行包含两个整数n和w(1<=n<=10^5,1<=w<=10^9)——n代表Pasha的朋友中男孩子的人数(和女孩子的人数相等),w代表Pasha的茶壶的容量。(单位:毫升)\ 输入文件的第二行是一系列的数字ai (1<=ai<=10^9,1<=i<=2n)——代表Pasha的每个茶杯的容量。 \ \ 输出格式:\ 只需输出一个实数——不违背上述规则的情况下Pasha能倒给他的朋友的水的最大体积(单位:毫升)。如果你的答案和标准答案之间的误差小于10^-6将会被认为是正确的。 \ \ 提示\ Pasha其实还准备了一些准备给女孩子们的糖果,但那是另一回事了……qwq

加入题单

算法标签: