QOJ.ac

QOJ

実行時間制限: 5.0 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#12324. 计算平均值

統計

Bytelandian 学校有一种相当独特的平均分计算系统。学生的成绩由一个包含 $n$ 个整数的数组 $a$ 表示。学期末,老师会从数组 $a$ 中选择一个下标为 $k$ 的成绩。随后,学生可以选择任何包含第 $k$ 个成绩的连续子段。最终成绩即为该子段中所有成绩的平均值。

你在 Bytelandian 的一所学校学习,想要知道你能获得什么样的成绩。由于你不知道老师会选择哪个下标,你需要计算出对于每个可能的下标 $k$,所能获得的最高平均分。形式化地说,对于每个 $k$,你需要找到包含数组 $a$ 中第 $k$ 个元素的子段所能达到的最大平均值。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 2 \cdot 10^5$),表示成绩的数量。

第二行包含 $n$ 个整数 $a_i$ ($0 \le a_i \le 10^9$),由空格分隔,表示你的成绩数组。

输出格式

输出 $n$ 行。第 $i$ 行输出当老师选择下标 $i$ 时,所能获得的最高平均分。如果答案的绝对误差或相对误差不超过 $10^{-6}$,则视为正确。

样例

输入 1

6
2 4 5 7 3 6

输出 1

4.500000
5.333333
6.000000
7.000000
5.333333
6.000000

说明

对于 $k = 1$,你可以选择整个数组,答案为 $\frac{2+4+5+7+3+6}{6} = 4.5$。

对于 $k = 2$,你可以选择第 2、第 3 和第 4 个成绩,答案为 $\frac{4+5+7}{3} = 5\frac{1}{3}$。

对于 $k = 3$,你可以选择第 3 和第 4 个成绩,答案为 $\frac{5+7}{2} = 6$。

对于 $k = 4$,你可以选择第 4 个成绩,得到答案 7。

对于 $k = 5$,你可以选择最后三个成绩,得到答案 $\frac{7+3+6}{3} = 5\frac{1}{3}$。

对于 $k = 6$,你可以选择最后一个成绩,得到答案 6。

可以证明这些答案是最优的。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.