Green Energy
Time limit1sMemory limit128 MB
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.
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 towers to mount, and they are already bought. The height of the -th tower is . 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 vertices. The vertices have coordinates with . A tower stands vertically at a point of this landscape, and the coordinate of that point may be any real number between and .
The sun angle in Flatland is always 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 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 , and (, , ). The second line contains heights of the towers (). Each of the next lines contains the coordinates , of one landscape vertex (, , ).
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.