CF557B.Pasha and Tea
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
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 2_x_ 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.
帕沙决定邀请他的朋友们来参加一场茶会。为此,他准备了一个容量为 w 毫升的大茶壶,以及 2n 个茶杯,每个茶杯供帕沙的一位朋友使用。第 i 个茶杯最多可盛 ai 毫升水。
结果发现,帕沙的朋友中恰好有 n 位男孩和 n 位女孩,且他们都会来参加茶会。为了使每位朋友都感到满意,帕沙决定按如下方式倒茶:
- 帕沙只能将水烧开一次,即向茶壶中注入至多 w 毫升的水;
- 帕沙给每位女孩倒入相同量的水;
- 帕沙给每位男孩倒入相同量的水;
- 若每位女孩得到 x 毫升水,则每位男孩得到 2x 毫升水。
换句话说,每位男孩得到的水量应是每位女孩的两倍。
帕沙非常友善且有礼貌,因此他希望最大化倒入朋友们杯中的水的总量。你的任务是帮助他确定茶杯在朋友们之间分配的最优方案。
输入格式
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.
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.
输入的第一行包含两个整数 n 和 w(1 ≤ n ≤ 105,1 ≤ w ≤ 109)—— 分别表示帕沙的男性朋友人数(等于帕沙的女性朋友人数)以及帕沙茶壶的容量(单位:毫升)。
输入的第二行包含一个整数序列 ai(1 ≤ ai ≤ 109,1 ≤ i ≤ 2n)—— 表示帕沙的各个茶杯的容量(单位:毫升)。
输出格式
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.
输出一个实数——Pasha 在不违反给定条件的前提下,最多能倒入朋友们杯中的水的总量(单位:毫升)。若你的答案的绝对或相对误差不超过 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...
帕沙还有一些糖果,他打算把这些糖果分给女孩们,但那是另一个任务了……
输入解题思路,AI测评打分。不知道怎么写?