ICPC 2019 · Problem B · Beautiful Bridges

43rd ICPC · Porto, Portugal

Statement

Time limit: 10 seconds

Example of a Roman arch bridge. Source: Wikimedia Commons What connects us all? Well, it is often bridges. Since an- cient times, people have been building bridges for roads, for trains, for pedestrians, and as aqueducts to transport water. It is humanity’s way of not taking inconvenient geography for an answer.

The company Arch Bridges Construction (ABC) specializes in–you guessed it–the construction of arch bridges. This classical style of bridge is supported by pillars that extend from the ground below the bridge. Arches between pillars dis- tribute the bridge’s weight onto the adjacent pillars.

The bridges built by ABC often have pillars spaced at irregular intervals. For aesthetic reasons, ABC’s bridges always have semicircular arches, as illustrated in Figure B.1. However, while a bridge arch can touch the ground, it cannot extend below the ground. This makes some pillar placements impossible.

Figure B.1: Bridge examples.

Figure B.1: Bridge examples.

Given a ground profile and a desired bridge height hh, there are usually many ways of building an arch bridge. We model the ground profile as a piecewise-linear function described by nn key points (x1,y1),(x2,y2),...,(xn,yn)(x_{1}, y_{1}),(x_{2}, y_{2}), . . . ,(x_{n}, y_{n}), where the xx-coordinate of a point is the position along the bridge, and the yy-coordinate is the elevation of the ground above sea level at this position along the bridge. The first and last pillars must be built at the first and last key points, and any intermediate pillars can be built only at these key points. The cost of a bridge is the cost of its pillars (which is proportional to their heights) plus the cost of its arches (which is proportional to the amount of material used). So a bridge with kk pillars of heights h1,...,hkh_{1}, . . . , h_{k} that are separated by horizontal distances d1,...,dk1d_{1}, . . . , d_{k- 1} has a total cost of

α\alpha \cdot kk XX

i=1i=1 hi+βhi+\beta \cdot k1k- 1 XX

i=1i=1 d2d^{2} ii

for some given constants α\alpha and β\beta. ABC wants to construct each bridge at the lowest possible cost.

ICPC World Finals 2019 Problem B: Beautiful Bridges

Input

The first line of input contains four integers nn, hh, α\alpha, and β\beta, where nn (2n1042 \le n \le 10^{4}) is the number of points describing the ground profile, hh (1h1051\le h\le 10^{5}) is the desired height of the bridge above sea level, and α\alpha, β\beta (1α,β1041\le \alpha , \beta \le 10^{4}) are the cost factors as described earlier. Then follow nn lines, the iith of which contains two integers xix_{i}, yiy_{i} (0x1<x2<...<xn1050 \le x1 < x2 < . . . < xn \le 10^{5} and 0yi<h0 \le yi < h), describing the ground profile.

Output

Output the minimum cost of building a bridge from horizontal position x1x_{1} to xnx_{n} at height hh above sea level. If it is impossible to build any such bridge, output impossible.

Sample Input 1

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

Sample Output 1

6460

Sample Input 2

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

Sample Output 2

impossible

ICPC World Finals 2019 Problem B: Beautiful Bridges

No official solution in the source collection.