Under construction

Still being built. Things may change

Green Energy

Time limit1sMemory limit128 MB

Summary
Place towers of given heights on a polygonal terrain to maximize the total length lit by parallel sun rays blocked by terrain and other towers.
Level

Hard9 of 10

Topics
Geometry, Greedy, Sorting
Solved
No attempts yet

Problem

Flatland is building solar power stations of a new type this year. The panels are not laid on the ground. They are mounted on the sides of tall towers, all the way up.

There are nn towers to mount, and they are already bought. The height of the ii-th tower is hih_i. The engineers now want to choose the points where the towers stand so that the total power is as large as possible.

The landscape of the plant territory is given as a polyline with mm vertices. The vertices have coordinates (xi,yi)(x_i, y_i) with xi<xi+1x_i < x_{i+1}. A tower stands vertically at a point of this landscape, and the xx coordinate of that point may be any real number between x1x_1 and xmx_m.

The sun angle in Flatland is always α\alpha degrees. The sun shines from the top left to the bottom right, and all rays are parallel to each other and make an angle of α\alpha degrees with the horizontal. The power produced by a tower is the length of its surface that the sun lights up. In other words, take the vertical segment that represents the tower: the power is the length of the part of that segment which a ray reaches without being blocked by the landscape or by another tower.

When two towers stand close to each other, the shadow of the left tower can fall onto the right one, and the power of the right tower drops. High points of the landscape drop shadows on towers as well.

Choose the points to mount the towers so that the total illuminated length of the tower surfaces is as large as possible.

Input

The first line contains three integers nn, mm and α\alpha (1≤n≤1041 \le n \le 10^4, 2≤m≤1042 \le m \le 10^4, 1≤α<901 \le \alpha < 90). The second line contains nn heights hih_i of the towers (1≤hi≤1031 \le h_i \le 10^3). Each of the next mm lines contains the coordinates xix_i, yiy_i of one landscape vertex (∣xi∣≤105|x_i| \le 10^5, xi<xi+1x_i < x_{i+1}, ∣yi∣≤103|y_i| \le 10^3).

Output

Print on one line the maximum total illuminated length of the tower surfaces, rounded to six digits after the decimal point, with all six digits written out. No input gives an answer close enough to a rounding boundary for the sixth digit to depend on the implementation.

Hint

Several towers may be mounted at the same point. In that case only the longest one among the towers mounted at that point counts as illuminated by the sun.

Examples2

  1. Example 1

    Input
    5 4 10
    20 10 20 15 10
    0 10
    40 20
    50 0
    70 30
    
    Expected output
    52.342889
    
  2. Example 2

    Input
    2 2 45
    3 4
    0 0
    20 0
    
    Expected output
    7.000000