codeforces #311 B B. Pasha and Tea(贪心)
来源:互联网 发布:淘宝网cf 编辑:程序博客网 时间:2024/05/16 18:23
题目链接:
点击打开链接
题目大意:
给出一个壶,能装w升水,给你2*n个杯子,每个杯子有自己的容量,然后n个杯子给女生加x升水,n个杯子给男生加2*x升水,问x最大的方案需要多少水
题目分析:
首先(x+2*x)*n = w ,求出一个上限
然后对杯子进行排序,a[n]/2提供一个上限
a[1]提供一个下限
然后判断一下就能得到结果,水题一枚。。。。
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#define MAX 100007using namespace std;int a[MAX*3];int w,n;int main ( ){ while ( ~scanf ( "%d%d" , &n , &w ) ) { double x = w*1.0/(3*n); for ( int i = 0 ; i <2*n ; i++ ) scanf ( "%d" , &a[i] ); sort ( a , a+2*n ); double y = a[n]*1.0/2.0; y = min ( y , (double)a[0] ); if ( x > y ) printf ( "%.8lf\n" , y*3*n ); else printf ( "%.8lf\n" , (double)w ); }}
0 0
- codeforces #311 B B. Pasha and Tea(贪心)
- CodeForces#311 B. Pasha and Tea
- CF 557B(Pasha and Tea-贪心)
- B. Pasha and Tea
- codeforces B. Pasha and Tea二分
- codeforces 557B Pasha and Tea-水题
- CodeForces 557B Pasha and Tea
- Codeforces 557B Pasha and Tea 【数学】
- CodeForces 557B-Pasha and Tea【模拟】
- CodeForces 557B Pasha and Tea
- 【23.33%】【codeforces 557B】Pasha and Tea
- Codeforces Round #311 (Div. 2) B. Pasha and Tea
- Codeforces Round #311 (Div. 2) B. Pasha and Tea
- Codeforces Round #311 (Div. 2) B. Pasha and Tea【二分】
- B. Pasha and Tea( Codeforces Round #311 (Div. 2) )
- Codeforces Round #311 (Div. 2)-B. Pasha and Tea-水题
- cf#311 B. Pasha and Tea
- Codeforces 557B Pasha and Tea 倒茶
- POJO和javabean的异同
- NGINX引入线程池 性能提升9倍
- android圆角矩形框xml的实现
- apache如何解决跨域资源访问
- Hyper-V 高可用性 (存储配置篇2)
- codeforces #311 B B. Pasha and Tea(贪心)
- C#中图片BYTE[]和base64string的相互转换
- ZeroMQ的学习和研究
- 初创企业都采用哪种开源协议?
- Date String Timestamp之间的相互转化
- 安卓上传本地图片闪退
- XmlReader在未知元素的名称和属性的名称的情况下读取属性
- StreamReader读取文件时出现乱码的解决方案
- C#窗体传值方法总结