NYOj 976 Youth的最大化
来源:互联网 发布:软件qa岗位职责 编辑:程序博客网 时间:2024/06/05 13:26
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int n,k;double s[10005],w[10005],v[10005];bool Greedy(double x){ for(int i = 0;i < n;i++) s[i] = v[i] - x * w[i]; sort(s,s+n); double sum = 0; for(int i = n-k;i < n;i++) sum += s[i]; if(sum >= 0) return true; return false;}void search(double l,double r){ while(r - l > 0.0000001) { double mid = (l + r) / 2; if(Greedy(mid)) l = mid; else r = mid; } printf("%.2lf\n",l);}int main(){ while(~scanf("%d%d",&n,&k)) { double max = 0; for(int i = 0;i < n;i++) { scanf("%lf%lf",&w[i],&v[i]); if(max < v[i]/w[i]) max = v[i]/w[i]; } search(0,max); }}
这个是关键
0 0
- NYOj 976 Youth的最大化
- nyoj-976-Youth的最大化(贪心+二分)
- NYOJ Yougth的最大化
- NYOJ 914 Yougth的最大化
- NYOJ 914 Yougth的最大化
- nyoj-914 Yougth的最大化
- NYOJ - 914 Yougth的最大化
- Yougth的最大化 nyoj 914
- NYOJ-914 Yougth的最大化
- NYOJ 914 Yougth的最大化
- NYOJ 914 Yougth的最大化
- NYOJ-914 Yougth的最大化
- nyoj 914 Yougth的最大化
- NYOJ 914 Yougth的最大化
- NYOJ 914 Yougth的最大化 【贪心】+【二分】
- NYOJ 914-Yougth的最大化(二分)
- nyoj 题目914 Yougth的最大化
- YOUTH
- Wireless Network
- OC的内存管理
- poj 3080 Blue Jeans
- 面试经典题
- test9.18
- NYOj 976 Youth的最大化
- 整数除法
- Looper、Handler与HandlerThread
- 【学习笔记】C语言 随机数的生成原理分析和各类随机数公式
- HDFS原理及其个元素功能
- php中的几个输出函数
- poj2452
- numpy 矩阵运算的陷阱
- 程序设计基石与实践专栏引导