poj 2976 Dropping tests
http://poj.org/problem?id=2976
这道题就是从n个a[i]和b[i]中去掉k个a[i]和[i]使得.最大。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 20000
using namespace std;
const double eps=1e-; double a[maxn],b[maxn],c[maxn];
int n,k; int main()
{
while(scanf("%d%d",&n,&k)!=EOF)
{
if(n==&&k==) break;
for(int i=; i<n; i++)
{
scanf("%lf",&a[i]);
}
for(int i=; i<n; i++)
{
scanf("%lf",&b[i]);
}
double l=0.0;
double r=1.0;
double mid;
while(r-l>eps)
{
double sum=;
mid=(l+r)/;
for(int i=; i<n; i++)
{
c[i]=a[i]-mid*b[i];
}
sort(c,c+n);
for(int j=k; j<n; j++)
{
sum+=c[j];
}
if(sum>)
l=mid;
else
r=mid;
}
printf("%.0f\n",mid*);
}
return ;
}
poj 2976 Dropping tests的更多相关文章
- POJ - 2976 Dropping tests && 0/1 分数规划
POJ - 2976 Dropping tests 你有 \(n\) 次考试成绩, 定义考试平均成绩为 \[\frac{\sum_{i = 1}^{n} a_{i}}{\sum_{i = 1}^{n} ...
- 二分算法的应用——最大化平均值 POJ 2976 Dropping tests
最大化平均值 有n个物品的重量和价值分别wi 和 vi.从中选出 k 个物品使得 单位重量 的价值最大. 限制条件: <= k <= n <= ^ <= w_i <= v ...
- POJ 2976 Dropping tests 【01分数规划+二分】
题目链接:http://poj.org/problem?id=2976 Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total S ...
- POJ 2976 Dropping tests(01分数规划入门)
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11367 Accepted: 3962 D ...
- POJ 2976 Dropping tests 01分数规划 模板
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6373 Accepted: 2198 ...
- POJ 2976 Dropping tests(01分数规划)
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions:17069 Accepted: 5925 De ...
- POJ 2976 Dropping tests (0/1分数规划)
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4654 Accepted: 1587 De ...
- Poj 2976 Dropping tests(01分数规划 牛顿迭代)
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Description In a certain course, you take n t ...
- poj 2976 Dropping tests 二分搜索+精度处理
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8349 Accepted: 2919 De ...
- poj 2976 Dropping tests (二分搜索之最大化平均值之01分数规划)
Description In a certain course, you take n tests. If you get ai out of bi questions correct on test ...
随机推荐
- 《Programming WPF》翻译 第9章 3.自定义功能
原文:<Programming WPF>翻译 第9章 3.自定义功能 一旦你挑选好一个基类,你将要为你的控件设计一个API.大部分WPF元素提供属性暴露了多数功能,事件,命令,因为他们从框 ...
- statfs函数说明
函数: statfs 功能描述: 查询文件系统相关的信息. 用法: #include <sys/vfs.h> /* 或者 <sys/statfs.h> ...
- POJ Oulipo (KMP)
题目大意 : 在一个字符串中找出目标单词的个数 代码: #include<iostream> #include<cstdio> #include<cstdlib> ...
- Android Call requires API level 11 (current min is 8)的解决方案
[错误描述] 在用Eclipse开发过程中,为了兼容Android2.2和4.0以上版本,我在使用Notification类时做了2个版本的代码,代码根据系统版本不同执行相应模块,结果,等我输完代码, ...
- 《Java程序员面试笔试宝典》之为什么需要public static void main(String[] args)这个方法
public staticvoid main(String[] args)为Java程序的入口方法,JVM在运行程序的时候,会首先查找main方法.其中,public是权限修饰符,表明任何类或对象都可 ...
- RCU 机制 [转IBM]
2005 年 7 月 01 日 本文详细地介绍了 Linux 2.6 内核中新的锁机制 RCU(Read-Copy Update) 的实现机制,使用要求与典型应用. 一.引言 众所周知,为了保护共享数 ...
- C++里消除Wunused
编译程序时,有一大堆警告总是不爽的.别人的代码也就忍了,不好去改.自己的可没法忍.看看C++里怎么消除Wunused警告. 先来看下面的程序: #include <iostream> in ...
- wpf纯前台绑定
<Window x:Class="Example1.MainWindow" ... xmlns:local="clr-namespace:Example1" ...
- Unity SendMessage方法
我们今天研究下SendMessage方法, 如果我们需要执行某一个组件的方法时候可以使用SendMessage gameObject.SendMessage("A"); 即可通知当 ...
- Eclipse 里的 Classpath Variables M2_REPO 无法修改(maven)
解决方法: 在C:\Documents and Settings\Administrator\.m2中放入setting.xml,并修改本地仓库为 <localRepository>D ...