QOJ.ac

QOJ

时间限制: 3.0 s 内存限制: 1024 MB 总分: 100

#8524. 天气预报

统计

Radewoosh 是一位气象学家。通过他的研究站,他已经获知了未来 $n$ 天的预测气温。每一天的气温(以 Bytenheit 度为单位)始终是一个正整数。

Radewoosh 现在需要在电视上发布天气预报。为了让厌倦了寒冷气候的人们感到高兴,他决定营造一种天气会很温暖的印象。他决定将未来 $n$ 天划分为 $k$ 个非空区间,使得每一天恰好属于一个区间。然后,在天气预报中,Radewoosh 将只提供 $k$ 个数字——即各区间内天数气温的算术平均值。

Radewoosh 知道,观看预报的观众非常害怕低温。因此,他希望进行一种划分,使得他所提供的所有周期中,平均气温最低的那个周期的平均气温尽可能高(如果一个周期的平均气温不高于其余任何周期的平均气温,我们就称该周期为最冷周期)。请帮助他完成这样的划分!

输入格式

第一行包含两个整数 $n$ 和 $k$ ($1 \le n \le 2 \cdot 10^5$, $1 \le k \le n$),分别表示 Radewoosh 拥有气温预测的天数,以及他想要划分的周期数。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 1000$),表示连续几天的气温,以 Bytenheit 度为单位。

输出格式

输出一个实数,表示所有周期中平均气温最低的那个周期的最大可能平均气温。如果你的答案与标准答案的绝对误差不超过 $10^{-4}$,则该答案将被接受。

样例

输入 1

7 3
1 3 1 2 2 2 1

输出 1

1.666666666667

说明

这些天可以划分为如下周期:$[1, 3, 1]$, $[2]$, $[2, 2, 1]$。连续区间的平均气温分别为 $\frac{5}{3}$, $2$, 和 $\frac{5}{3}$,由此得到的最低平均气温为 $\frac{5}{3}$。这种划分方式使得单个周期内的最低平均气温达到了最大值。

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.