博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ - 2976 Dropping tests
阅读量:5268 次
发布时间:2019-06-14

本文共 2264 字,大约阅读时间需要 7 分钟。

In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be

.

Given your test scores and a positive integer k, determine how high you can make your cumulative average if you are allowed to drop any k of your test scores.

Suppose you take 3 tests with scores of 5/5, 0/1, and 2/6. Without dropping any tests, your cumulative average is . However, if you drop the third test, your cumulative average becomes .

Input

The input test file will contain multiple test cases, each containing exactly three lines. The first line contains two integers, 1 ≤ n ≤ 1000 and 0 ≤ k < n. The second line contains n integers indicating ai for all i. The third line contains n positive integers indicating bi for all i. It is guaranteed that 0 ≤ ai ≤ bi ≤ 1, 000, 000, 000. The end-of-file is marked by a test case with n = k = 0 and should not be processed.

Output

For each test case, write a single line with the highest cumulative average possible after dropping k of the given test scores. The average should be rounded to the nearest integer.

Sample Input

3 15 0 25 1 64 21 2 7 95 6 7 90 0

Sample Output

83100

Hint

To avoid ambiguities due to rounding errors, the judge tests have been constructed so that all answers are at least 0.001 away from a decision boundary (i.e., you can assume that the average is never 83.4997).

二分基础题

1 #include 
2 using namespace std; 3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 #include
16 #include
17 double a[1100];18 double b[1100];19 double c[1100];20 const double MIN=1e-7;21 int n,m;22 int main()23 {24 while(cin>>n>>m)25 {26 if(n==0&&m==0)27 break;28 for(int i=1;i<=n;i++)29 cin>>a[i];30 for(int i=1;i<=n;i++)31 cin>>b[i];32 double kaishi=0.0,jieshu=1.0;33 double mid;34 while(jieshu-kaishi>MIN)35 {36 mid=(kaishi+jieshu)/2.0;37 //cout<
<<"_"<
=0)45 kaishi=mid;46 else47 jieshu=mid;48 }49 int qqq=mid*1000;50 if(qqq%10>=5)51 qqq+=10;52 qqq/=10;53 cout<
<
View Code

 

转载于:https://www.cnblogs.com/dulute/p/7966690.html

你可能感兴趣的文章
slab分配器
查看>>
【读书笔记】C#高级编程 第三章 对象和类型
查看>>
【SVM】libsvm-python
查看>>
Jmeter接口压力测试,Java.net.BindException: Address already in use: connect
查看>>
Leetcode Balanced Binary Tree
查看>>
go:channel(未完)
查看>>
[JS]递归对象或数组
查看>>
多线程《三》进程与线程的区别
查看>>
linux sed命令
查看>>
html标签的嵌套规则
查看>>
[Source] Machine Learning Gathering/Surveys
查看>>
HTML <select> 标签
查看>>
tju 1782. The jackpot
查看>>
湖南多校对抗赛(2015.03.28) H SG Value
查看>>
hdu1255扫描线计算覆盖两次面积
查看>>
hdu1565 用搜索代替枚举找可能状态或者轮廓线解(较优),参考poj2411
查看>>
bzoj3224 splay板子
查看>>
程序存储问题
查看>>
Mac版OBS设置详解
查看>>
优雅地书写回调——Promise
查看>>