QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#1440. 山丘

统计

Zenyk 和 Marichka 准备好雪球,想要开始一场游戏。 但突然,Zenyk 觉得在平地上扔雪球太无聊了。他想堆一座尽可能高的山,以便自己爬上去向 Marichka 扔雪球。

堆山并不容易。Zenyk 非常认真地对待这件事,他拿出一张带有坐标轴的纸,其中 $y$ 轴向上,并开始绘制山的横截面(正视图)。

Marichka 不希望山太高,因此她对山的截面施加了一些限制:

  1. 截面必须是一条折线。
  2. 折线必须从点 $(x_0, y_0)$ 开始,并在点 $(x_n, y_n)$ 结束。
  3. 折线必须包含 $n$ 条线段。
  4. 第 $i$ 条线段的长度应为 $l_i$。

Zenyk 想知道在这些限制下他能堆出的山的最大高度,并请求你找出山截面上的最大 $y$ 坐标。请帮帮他。

输入格式

第一行包含四个整数 $x_0, y_0, x_n, y_n$ ($|x_0|, |y_0|, |x_n|, |y_n| \le 10^6$),表示折线的起点和终点坐标。

第二行包含一个整数 $n$ ($1 \le n \le 10^5$),表示折线中的线段数量。

第三行包含 $n$ 个整数 $l_1, \dots, l_n$ ($1 \le l_i \le 10^6$),表示各线段的长度。

输出格式

如果不存在满足这些限制的山,输出 “IMPOSSIBLE”。

否则,输出一个实数,表示最高点的最大 $y$ 坐标。如果输出结果的绝对误差或相对误差不超过 $10^{-7}$,则视为正确。

样例

样例输入 1

2 3 8 3
2
5 5

样例输出 1

7.0000000000

样例输入 2

4 7 44 77
4
4 7 7 4

样例输出 2

IMPOSSIBLE

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.