Pasha and Tea

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 ai 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.

Input

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 ai (1 ≤ ai ≤ 109, 1 ≤ i ≤ 2n) — the capacities of Pasha's tea cups in milliliters.

Output

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.

Sample test(s)
Input
2 4
1 1 1 1
Output
3
Input
3 18
4 4 4 2 2 2
Output
18
Input
1 5
2 3
Output
4.5
Note

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

最多可以用多少水,看是女生用的多还是男生可以用的多,毕竟还有二倍限制

 #include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <limits>
#include <queue>
#include <stack>
#include <vector>
#include <map> using namespace std; #define N 200005
#define INF 0xfffffff
#define PI acos (-1.0)
#define EPS 1e-8
#define Lson rt<<1, l, tree[rt].mid ()
#define Rson rt<<1|1, tree[rt].mid () + 1, r int main ()
{
int n;
double w, a[N]; while (~scanf ("%d%lf", &n, &w))
{
for (int i=; i<*n; i++)
scanf ("%lf", &a[i]); sort (a, a+*n); double ans = min (a[], a[n]/);
ans = ans * * n;
ans = min (w*1.0, ans); printf ("%.7f\n", ans);
}
return ;
}

也可以二分,因为你二分学的好(话说,二分是什么

http://blog.csdn.net/u014427196

最新文章

  1. log4net 2.0.4有问题,AdoNetAppender会报错
  2. Solr与MySQL查询性能对比
  3. Atitit GRASP(General Responsibility Assignment Software Patterns),中文名称为“通用职责分配软件模式”
  4. HTML 30分钟入门教程
  5. 【bzoj2120】 数颜色
  6. centos7 怎么卸载 用源代码包安装的codeblocks
  7. android环境部署(1.1)
  8. Android系统中Parcelable和Serializable的区别
  9. php透明合并png与jpg图片
  10. javascript中的字符串编码、字符串方法详解
  11. IBM GPFS并行文件系统
  12. Git使用六:版本对比
  13. go mysql insert变量到数据库
  14. 2018牛客网暑假ACM多校训练赛(第七场)I Tree Subset Diameter 动态规划 长链剖分 线段树
  15. C++11 多线程编程 使用lambda创建std::thread (生产/消费者模式)
  16. virsh详解
  17. Tomcat 6 部署工程总结,使用JNDI数据源配置
  18. 微软正式发布VS2015和.Net为开发者提供数百个新功能
  19. 搭建psdash 监控系统
  20. [转]如何清空Chrome缓存和Cookie

热门文章

  1. delphi 获取文件的最新修改时间 http://www.delphitop.com/html/wenjian/64.html
  2. delphi idhttpsever
  3. Unity3D架构之PureMVC
  4. 手撸红黑树-Red-Black Tree 入门
  5. 微信小程序这一块(续)
  6. [CF960G]Bandit Blues(第一类斯特林数+分治卷积)
  7. 推荐一个 Java 里面比较牛逼的公众号!
  8. Codeforces 1105D (BFS)
  9. Codeforces 375D D. Tree and Queries
  10. React中异步模块api React.lazy和React.Suspense