Codeforces Round #311 (Div. 2)(B)排序
来源:互联网 发布:mac 图像处理软件 编辑:程序博客网 时间:2024/06/05 02:59
题意:有n个男孩,n个女孩。有2*n个茶壶,一共有W毫升的茶水。当每个女孩得到x毫升的水,那么男孩就必须获得2*x的水,问最多可以倒出多少水
题解:先排序,求出这次倒水量的上界 男孩的最小容量和女孩的最小容量:max=min(a[n+1]/2,a[1]),最多只能倒出这么多的水(max*3*n),如果可以容下所有的水,那么直接输出w
#include <set>#include <map>#include <list> #include <cmath> #include <queue> #include <vector>#include <cstdio> #include <string> #include <cstring>#include <iomanip> #include <iostream> #include <sstream>#include <algorithm>#define LL long long using namespace std;#define N 200000double a[N<<1];int main(){#ifdef CDZSCfreopen("i.txt","r",stdin);#endifint mx[10],mn[10];int n;double w;while(~scanf("%d%lf",&n,&w)){for(int i=1;i<=2*n;i++){scanf("%lf",a+i);}sort(a+1,a+2*n+1);double mx=min(a[n+1]/2,a[1]);mx*=3;printf("%.10lf",n*mx>=w?w:(double(n)*mx));puts("");}return 0;}
0 0
- Codeforces Round #311 (Div. 2)(B)排序
- Codeforces Round #346 (Div. 2)-B. Qualifying Contest(排序)
- Codeforces Round #346 (Div. 2)(B)排序,模拟
- Codeforces Round #311 (Div. 2) Problem B
- Codeforces Round #256 (Div. 2)(B)
- Codeforces Round #350 (Div. 2)(B)
- Codeforces Round #379 (Div. 2)B
- B. Pasha and Tea( Codeforces Round #311 (Div. 2) )
- Codeforces Round #448 (Div. 2) B. XK Segments 排序+二分
- Codeforces Round #311 (Div. 2) B. Pasha and Tea
- Codeforces Round #311 (Div. 2) B. Pasha and Tea
- Codeforces Round #311 (Div. 2) A B C D
- Codeforces Round #311 (Div. 2) A,B,C,D,E
- Codeforces Round #311 (Div. 2) B. Pasha and Tea【二分】
- Codeforces Round #311 (Div. 2)-B. Pasha and Tea-水题
- B. Inventory(Codeforces Round #315 (Div. 2)水题)
- Codeforces Round #154 (Div. 2) B题(Physics Practical)
- Codeforces Round #151 (Div. 2)——B
- GNU ARM 汇编伪指令备忘录
- ubuntu创建快捷方式
- hadoop_7 : MapReduce续
- 解决Unable to connect to a repository at URL 禁止访问 (forbidden)
- Scala 第十三章 集合
- Codeforces Round #311 (Div. 2)(B)排序
- 矩阵运算的重新理解
- 无人值守安装linux
- 2.1 UIAlertView,UIActionSheet,UIDatePicker,UIPickerView使用的简单总结
- 亲手造的一个轮子--jiptux
- 深度学习之theano学习的一些网址
- POJ Fibonacii (矩阵快速幂)
- 如何在tomcat里为多个应用配置不同的访问端口
- Plugin is too old,please update to a more recent version,or set ANDROID_DAILY_OVERRIDE environment v