Problem list
Log in
#usaco0145 · USACO 2013-2014 March Gold

Sabotage

Platinum III 2.0 s 256 MB

Farmer John's arch-nemesis, Farmer Paul, has decided to sabotage Farmer John's milking equipment!

The milking equipment consists of a row of N (3 <= N <= 100,000) milking machines, where the ith machine produces M_i units of milk (1 <= M_i <= 10,000). Farmer Paul plans to disconnect a contiguous block of these machines -- from the ith machine up to the jth machine (2 <= i <= j <= N-1); note that Farmer Paul does not want to disconnect either the first or the last machine. Farmer Paul's goal is to minimize the average milk production of the remaining machines. Farmer Paul plans to remove at least 1 cow.

Please help Farmer John figure out the minimum average milk production of the remaining machines if Farmer Paul does succeed.

Input

  • Line 1: The integer N.
  • Lines 2..1+N: Line i+1 contains M_i.

Output

The lowest possible average Farmer Paul can achieve, rounded to 3 digits after the decimal point, and printed with 3 digits after the decimal point.

Example 1

Input
5
5
1
7
8
2
Output
2.667

Output details: The optimal solution removes the 7 and 8, leaving 5, 1, and 2, whose average is 8/3.

Source
USACO 2013-2014 March Gold
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code