QOJ.ac

QOJ

実行時間制限: 10 s メモリ制限: 2048 MB 満点: 100

#2338. 美丽的桥梁

統計

什么连接着我们所有人?嗯,通常是桥梁。自古以来,人们一直在建造桥梁,用于道路、火车、行人通行,以及作为输送水的渡槽。这是人类面对不便地理环境时给出的答案。

Arch Bridges Construction (ABC) 公司专门从事——你猜对了——拱桥的建造。这种经典的桥梁风格由从桥下地面延伸出的桥墩支撑。桥墩之间的拱门将桥梁的重量分配到相邻的桥墩上。

ABC 公司建造的桥梁通常桥墩间距不均匀。出于美观考虑,ABC 的桥梁总是采用半圆形拱门,如图 B.1 所示。然而,虽然桥拱可以接触地面,但它不能延伸到地面以下。这使得某些桥墩的放置位置变得不可行。

图 B.1:桥梁示例。

给定地面轮廓和期望的桥梁高度 $h$,通常有多种建造拱桥的方法。我们将地面轮廓建模为由 $n$ 个关键点 $(x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)$ 描述的分段线性函数,其中点的 $x$ 坐标是沿桥的位置,而 $y$ 坐标是该位置地面高于海平面的高度。第一根和最后一根桥墩必须建在第一个和最后一个关键点上,任何中间的桥墩只能建在这些关键点上。桥梁的成本是其桥墩的成本(与它们的高度成正比)加上其拱门的成本(与所用材料量成正比)。因此,一座拥有 $k$ 根高度分别为 $h_1, \dots, h_k$ 的桥墩,且相邻桥墩间水平距离分别为 $d_1, \dots, d_{k-1}$ 的桥梁,其总成本为

$$\alpha \cdot \sum_{i=1}^{k} h_i + \beta \cdot \sum_{i=1}^{k-1} d_i^2$$

其中 $\alpha$ 和 $\beta$ 为给定的常数。ABC 公司希望以尽可能低的成本建造每一座桥梁。

输入格式

输入的第一行包含四个整数 $n, h, \alpha$ 和 $\beta$,其中 $n$ ($2 \le n \le 10^4$) 是描述地面轮廓的点数,$h$ ($1 \le h \le 10^5$) 是桥梁距离海平面的期望高度,$\alpha, \beta$ ($1 \le \alpha, \beta \le 10^4$) 是如前所述的成本因子。接下来有 $n$ 行,第 $i$ 行包含两个整数 $x_i, y_i$ ($0 \le x_1 < x_2 < \dots < x_n \le 10^5$ 且 $0 \le y_i < h$),描述了地面轮廓。

输出格式

输出从水平位置 $x_1$ 到 $x_n$ 且高度为 $h$ 的桥梁的最低建造成本。如果无法建造任何此类桥梁,则输出 impossible

样例

输入格式 1

5 60 18 2
0 0
20 20
30 10
50 30
70 20

输出格式 1

6460

输入格式 2

4 10 1 1
0 0
1 9
9 9
10 0

输出格式 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.