QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 256 MB مجموع النقاط: 100

#11907. 羊

الإحصائيات

每天,牧羊人都在一条无限长的一维牧场上照看一群羊。牧羊人在早上 $0$ 时刻将羊群带到牧场,并在晚上 $T$ 时刻将羊群带回谷仓。牧羊人和每只羊在一天中在牧场上的位置都可以描述为从 $[0, T]$ 到 $\mathbb{R}$ 的函数。

经过数千天的观察,牧羊人意识到,每一只想要攻击他羊群的狼都会选择一只足够孤独的羊。如果 $h : [0, T] \to \mathbb{R}$ 描述了牧羊人全天的位置,那么对于位置由 $s : [0, T] \to \mathbb{R}$ 描述的特定羊,其孤独度定义为: $$L(s, h) = \left( \max_{t \in [0, T]} (s(t) - h(t)) \right)^2 + \left( \min_{t \in [0, T]} (s(t) - h(t)) \right)^2$$

没有狼是无限勇敢的。如果一只羊的孤独度低于某只狼特定的阈值,狼就不会攻击这只羊。

牧羊人想知道是否有可能拯救所有的羊,因此,他希望遵循一条轨迹,使得最孤独的那只羊的孤独度最小化。羊是非常简单的动物,因此每只羊的位置总是可以用线性函数 $s(t) = a \cdot t + b$ 来描述,其中 $a$ 和 $b$ 为常数。虽然如上式所示,牧羊人非常聪明,但他也有点懒,所以他也想遵循一个线性函数。

给定所有羊的位置,并假设牧羊人的轨迹也是一个线性函数,计算最孤独的那只羊的最低可能孤独度。

输入格式

第一行包含一个正整数 $T$ ($1 \le T \le 100$)。这是牧羊人将羊群带回谷仓的时间。第二行包含一个正整数 $n$ ($1 \le n \le 100\,000$)。这是羊的数量。接下来的 $n$ 行中,每行包含两个整数 $a$ 和 $b$,描述了一只羊的轨迹 $s(t) = a \cdot t + b$。保证 $|a| \le 100\,000$ 且 $|b| \le 100\,000$。没有两只羊具有相同的轨迹。

输出格式

输出一行,包含一个实数:最孤独的那只羊的最小孤独度。你的答案与正确答案的误差不超过 $0.01$ 即可。在我们准备的所有测试中,答案最大为 $10^{10}$。

样例

输入 1

5
2
10 5
10 14

输出 1

40.5000

输入 2

3
4
3 0
3 4
4 -1
6 -8

输出 2

38.2500

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.