Under construction

Still being built. Things may change

Drinking Water

Time limit2sMemory limit1024 MB

Summary
Given n distinct values and up to k averaging operations on chosen subsets, find the maximum value h_1 can reach, printed to p decimal digits.
Level

Hard9 of 10

Topics
Binary search, Greedy, Math, Sorting
Solved
No attempts yet

Problem

There is an array of nn real numbers. The ii-th number is hih_i. Initially, all hih_i are distinct.

In each operation, you may choose any number of the hih_i and set the value of each chosen hih_i to the average of the chosen numbers. The chosen numbers do not need to be consecutive. For example, you may choose h1h_1 and h3h_3 without choosing h2h_2. You may apply the operation at most kk times.

Find the maximum possible value of h1h_1.

Input

The first line contains three positive integers nn, kk, and pp. They are the length of the array, the maximum number of operations, and the required precision.

The second line contains nn positive integers. The ii-th integer is hih_i. All hih_i are distinct, and 1≤hi≤1051 \le h_i \le 10^5.

Output

Print the maximum possible h1h_1 as a real number on one line. The integer part is required. Print the decimal point only if there is a decimal part. You may print at most 2p2p digits after the decimal point, and at least pp digits is recommended. The reference answer differs from the true answer by at most 10−2p10^{-2p}.

Your answer is correct if its absolute difference from the reference answer is less than 10−p10^{-p}. If the difference is at least 10−p10^{-p} but less than 10−510^{-5}, you receive 40% of the points for that test case.

Constraints

For all test cases, 3≤p≤30003 \le p \le 3000, 1≤n≤80001 \le n \le 8000, and 1≤k≤1091 \le k \le 10^9.

Hints

To guarantee precision, keep more than pp digits after the decimal point in arithmetic operations when possible. The reference solution for each subtask keeps the absolute error below 10−p10^{-p} when each operation keeps at most 65p\frac{6}{5}p digits after the decimal point.

A high-precision library, library.zip, is provided. Using it is optional.

The Decimal library supports addition, subtraction, multiplication, division, comparison, and conversion to and from double, integers, and strings. For multiplication and division, one operand must be an integer. You cannot multiply or divide two Decimal values.

The library defines the constant PP, the maximum absolute error of each operation, which is 10−P10^{-P}. In the C++ version, line 9 of drink_sample.cpp sets it with const int PREC = 2100;. In the C version, line 9 of drink_sample.c sets it with #define PREC 2100. In the Pascal version, lines 8 and 14 of drink_sample.pas both contain 2100. If you change PP, change every occurrence to the same value. Each operation takes O(P)O(P) time. Each Decimal instance takes at most 4P9+16\frac{4P}{9}+16 bytes.

When calling Decimal functions, follow these conditions:

  • Every intermediate Decimal value has an absolute value of at most 101810^{18}.
  • int and longint arguments have absolute values of at most 10910^9.
  • long long and int64 arguments have absolute values of at most 101810^{18}.
  • A double argument is a valid real number with absolute value at most 10910^9.
  • A string argument is a valid real number. A negative number starts with a minus sign, and a non-negative number has no sign. It has an integer part, then a decimal point, then a decimal part. The decimal point and decimal part may both be omitted. Its absolute value is at most 10910^9.
  • Do not divide by zero.
  • When converting a Decimal to a string, the number of digits after the decimal point must be greater than zero. In C, allocate enough space for the string returned by to_string_d(Decimal, char*, int).

The programs drink_sample.cpp/c/pas contain only the library. You may work on them directly, but you do not have to. The programs decimal_test.cpp/c/pas show how to use the Decimal library and each of its functions.

Examples2

  1. Example 1

    Input
    3 1 3
    1 4 3
    
    Expected output
    2.666667
    
  2. Example 2

    Input
    3 2 3
    1 4 3
    
    Expected output
    3.000000