POJ 2976/ZOJ 3068 Dropping tests 01 score planning, pojzoj

Source: Internet
Author: User

POJ 2976/ZOJ 3068 Dropping tests 01 score planning, pojzoj


Card accuracy 01 score planning...

Dropping tests
Time Limit:1000 MS   Memory Limit:65536 K
Total Submissions:6464   Accepted:2230

Description

In a certain course, you takeNTests. If you getAiOutBiQuestions correct on testI, Your cumulative average is defined to be

.

Given your test scores and a positive integerK, Determine how high you can make your cumulative average if you are allowed to drop anyKOf 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 containsNIntegers indicatingAiFor allI. The third line containsNPositive integers indicatingBiFor allI. It is guaranteed that 0 ≤AiBi≤ 1,000,000,000. The end-of-file is marked by a test caseN=K= 0 and shoshould not be processed.

Output

For each test case, write a single line with the highest cumulative average possible after droppingKOf the given test scores. The average shocould 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 demo-boundary (I. e ., you can assume that the average is never 83.4997 ).

Source

Stanford Local 2005


# Include <iostream> # include <cstring> # include <cstdio> # include <algorithm> using namespace std; const int maxn = 1111; const double eps = 1e-8; int n, k; double a [maxn], B [maxn]; double d [maxn]; bool check (double L) {for (int I = 0; I <n; I ++) {d [I] = a [I]-B [I] * L;} sort (d, d + n); double sum = 0 .; for (int I = k; I <n; I ++) {sum + = d [I];} if (sum> eps) return true; return false ;} int main () {while (scanf ("% d", & n, & k )! = EOF) {if (n = 0 & k = 0) break; for (int I = 0; I <n; I ++) scanf ("% lf", a + I); for (int I = 0; I <n; I ++) scanf ("% lf", B + I ); double low = 0, high = 1, mid, ans; while (low + eps 



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.