8394: Sabotage

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

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, since this will make his plot too easy to discover. Farmer Paul's goal is to minimize the average milk production of the remaining machines. Farmer Paul plans to remove at least 1 cow, even if it would be better for him to avoid sabotage entirely. Fortunately, Farmer John has learned of Farmer Paul's evil plot, and he is wondering how bad his milk production will suffer if the plot succeeds. Please help Farmer John figure out the minimum average milk production of the remaining machines if Farmer Paul does succeed.
农夫约翰的死敌,农夫保罗,决定破坏农夫

约翰的挤奶设备!



挤奶设备由一排N(3<=N<=100000)组成

挤奶机,其中第i台机器生产M\i单位的牛奶(1

<=M\u i<=10000)。农民保罗计划断开一个相邻街区的连接

从第i台机器到第j台机器(2<=

i<=j<=N-1);请注意,Farmer Paul不想断开连接

要么是第一台机器,要么是最后一台机器,因为这将构成他的阴谋

太容易发现。Farmer Paul的目标是最小化平均值

剩余机器的牛奶生产。农民保罗计划

移除至少1头牛,即使它最好避免

完全破坏。



幸运的是,农夫约翰知道了农夫保罗的邪恶阴谋

他想知道如果阴谋得逞,他的牛奶产量会受到多大影响

成功。请帮助农夫约翰计算出最低平均牛奶量

如果农民保罗成功的话,剩余机器的生产。


输入格式

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

输出格式

* Line 1: 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.
The optimal solution is to remove the 7 and 8, leaving 5, 1, and 2, whose average is 8/3.

输入样例 复制

5
5
1
7
8
2

输出样例 复制

2.667