poj2976 Dropping tests 二分
来源:互联网 发布:北控软件 怎么样 编辑:程序博客网 时间:2024/06/03 12:28
题意:已知n场考试,每场考试的共b[i]道题,答对a[i]道题,从这n场考试中删去K场,使最大,问该值最大为多少
最大化最小值问题 同poj3111 http://blog.csdn.net/dlutjwh/article/details/54318672
#include<cstdio>#include<iostream>#include<algorithm>using namespace std;int a[1005],b[1005],n,k;double c[1005];bool C(double x){for(int i=0;i<n;i++) c[i]=a[i]-x*b[i];sort(c,c+n);double sum=0;for(int i=0;i<n-k;i++) sum+=c[n-i-1];return sum>=0;}int main(){while((cin>>n>>k)&&(n!=0||k!=0)){ for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++){ cin>>b[i]; } double lb=0,ub=1.1; for(int i=0;i<100;i++){ double mid=(lb+ub)/2; if(C(mid)) lb=mid; else ub=mid; } ub=ub*100; int z=ub; if(double(ub-z)<0.5) cout<<z<<endl; else cout<<z+1<<endl;}}
0 0
- [二分]poj2976 Dropping tests
- poj2976 Dropping tests 二分
- POJ2976 Dropping tests 二分搜索
- ZOJ3068 POJ2976 Dropping tests,二分检索
- POJ2976 Dropping tests 最大化平均值(二分)
- POJ2976 Dropping tests (最大化平均值/二分)
- POJ2976-01分数规划&二分-Dropping tests
- poj2976 Dropping tests(二分答案)
- POJ2976--Dropping tests
- POJ2976-Dropping tests
- [POJ2976] Dropping tests
- POJ2976-Dropping tests
- poj2976(二分,最大值平均化模板)Dropping tests
- POJ2976:Dropping tests(二分法)
- POJ2976 Dropping tests (分数规划)
- POJ2976-Dropping tests-最大化平均值
- (最大化平均值)poj2976,Dropping tests
- [POJ2976][分数规划]Dropping tests[水题]
- 全屏沉浸式透明状态栏效果
- 何为web开发
- phpfile文件系统基础
- 10004--- Broadleaf电商系统开发(二) - 启动项目
- Java HashSet 集合
- poj2976 Dropping tests 二分
- Retrofit 最简单的快速入门及自己封装
- ELK实时日志分析平台
- web前端开发笔记
- java统计数量List<Map<String,Object>
- 正则表达式基础1
- 关于图片之下的背景图片
- 超级厉害的JavaScript —— ECMAScript 6 标准(11) —— Decorator
- SAP产品成本计算流程 (修订版)