QOJ.ac

QOJ

実行時間制限: 5 s メモリ制限: 128 MB 満点: 100

#11152. 高速公路

統計

Autobyte 公司正在参与 Byteland 高速公路的建设。直到最近,该公司还只在高速公路的起点收取通行费。然而,公司新任董事长 Byteasar 注意到,在这种情况下,客户支付的费用与他们在高速公路上行驶的距离(以 bytemiles 为单位)无关。因此,公司计划在整条高速公路上设置收费站。

在一次高速公路旅行中,Byteasar 利用车上的里程表记录了所有入口的位置(入口的位置是指其距离高速公路起点的距离)。公司决定将收费站均匀地分布在高速公路上。这意味着每两个相邻收费站之间的距离是相等的。同时,每两个相邻收费站之间必须有一个高速公路入口,且每两个相邻高速公路入口之间也必须有一个收费站。幸运的是,现有的入口位置使得这种安排成为可能。

你的任务是计算相邻收费站之间距离的最小值和最大值。形式化地说,我们要寻找 $l$ 的最小值和最大值,使得存在一个第一个收费站的位置 $b_0$,满足后续收费站位于 $b_0 + l, b_0 + 2l, \dots, b_0 + nl$ 的位置。按照上述程序确定的某个收费站的位置可能恰好与某个入口的位置重合。在这种情况下,收费站将设置在入口附近,即入口之前或之后。换句话说,第 $j$ 个入口的位置应包含在以下区间内:$[b_0 + (j - 1)l, b_0 + jl]$。

输入格式

第一行包含一个整数 $n$ ($3 \le n \le 1\,000\,000$):高速公路入口的数量。 第二行包含一个递增的整数序列 $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 10^9$)。这些序列元素是后续高速公路入口的位置。

输出格式

你的程序应输出两个实数,分别表示相邻收费站之间距离的最小值和最大值(以 bytemiles 为单位)。你可以假设这两个值之间的差不小于 $10^{-9}$。

如果你的结果包含在区间 $[x(1-\epsilon) - \epsilon, x(1+\epsilon) + \epsilon]$ 内,则被视为正确,其中 $x$ 是正确答案,$\epsilon = 10^{-8}$。因此,相对误差和绝对误差均达到 $10^{-8}$ 的答案将被接受。

样例

输入 1

6
2 3 4 5 6 7

输出 1

0.833333333333 1.250000000000

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.