CF380E.Sereja and Dividing

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let's assume that we have a sequence of doubles _a_1, _a_2, ..., a|a| and a double variable x. You are allowed to perform the following two-staged operation:

  1. choose an index of the sequence element i (1 ≤ i ≤ |a|);
  2. consecutively perform assignments: .

Let's use function g(a, x) to represent the largest value that can be obtained from variable x, using the described operation any number of times and sequence a.

Sereja has sequence _b_1, _b_2, ..., b|b|. Help Sereja calculate sum: . Record [b__i, b__i + 1, ..., b__j] represents a sequence containing the elements in brackets in the given order. To avoid problems with precision, please, print the required sum divided by |b|2.

假设我们有一个双精度浮点数序列 $ a_1, a_2, \dots, a_{|a|} $ 和一个双精度浮点变量 $ x $。允许执行如下两阶段操作:

  1. 选择序列中某个元素的下标 $ i $(满足 $ 1 \leq i \leq |a| $);
  2. 连续执行如下赋值操作:
    。

定义函数 $ g(a, x) $ 为:在给定序列 $ a $ 和初始值 $ x $ 的前提下,通过任意次数执行上述操作所能得到的 $ x $ 的最大可能值。

Sereja 拥有序列 $ b_1, b_2, \dots, b_{|b|} $。请帮助 Sereja 计算如下和式:
。
其中记号 $ [b_i, b_{i+1}, \dots, b_j] $ 表示由方括号内元素按给定顺序构成的子序列。
为避免精度问题,请输出所求和式除以 $ |b|^2 $ 后的结果。

输入格式

The first line contains integer |b| (1 ≤ |b| ≤ 3·105) — the length of sequence b. The second line contains |b| integers _b_1, _b_2, ..., b|b| (1 ≤ b__i ≤ 105).

第一行包含一个整数 ∣b∣|b|(1≤∣b∣≤3⋅1051 \leq |b| \leq 3 \cdot 10^5)——序列 bb 的长度。
第二行包含 ∣b∣|b| 个整数 b1,b2,…,b∣b∣b_1, b_2, \dots, b_{|b|}(1≤bi≤1051 \leq b_i \leq 10^5)。

输出格式

In a single line print a real number — the required sum divided by |b|2. Your answer will be considered correct if its absolute or relative error won't exceed 10 - 6.

在一行中输出一个实数——所求的和除以 ∣b∣2|\mathbf{b}|^2。若你的答案的绝对或相对误差不超过 10−610^{-6},则视为正确。

输入输出样例

  • 输入#1

    5
    1 2 3 4 1

    输出#1

    1.238750000000000

输入解题思路,AI测评打分。不知道怎么写?

首页