Improving the Grade Point Average
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Zenyk’s parents asked Zenyk to show his school diary. Let’s assume that there are \(n\) pages in Zenyk’s diary, and page \(i\) contains the grade \(a_i\). Zenyk decided to tear out some pages from the diary so that the arithmetic mean of the grades remaining on the un-torn pages is maximized. However, Zenyk’s parents might not believe that Zenyk actually has such grades if the sum of all remaining grades is less than \(x\).
Zenyk asks Marichka to help him determine the maximum average grade he can get if he optimally tears pages out of the diary.
Input
The first line contains a single integer — \(n\).
The second line contains \(n\) integers — \(a_1, a_2, ..., a_n\).
The third line contains a single integer — \(x\).
Output
In a single line, print one number — the maximum average grade Zenyk can get.
Your answer will be considered correct if the absolute or relative error does not exceed \(10^{-4}\).
Constraints
\(1 \le n \le 100\),
\(1 \le a_i \le 12\),
\(0 < x \le \sum_{i=1}^{n}a_i\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 5 12 12 1 12 11 47 | 11.7500 |
Notes
Zenyk can tear out the page with the grade 1. Then the sum of the grades will not be less than 47, and the average grade will be equal to 11.75.
If Zenyk also tore out the page with 11, the average grade would increase to 12, but the sum of the grades would be less than 47.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|