Ограничения: время – 3s/6s, память – 256MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод
Послать решение Blockly Посылки Темы Где Обсудить (0)
The technological progress in Flatland is impressive. This year, for example, the solar power stations
of a new type will be build. In these stations solar panels are mounted not on the ground, but on high
towers, along their heights.
There are n towers to be mounted. The towers are already bought. The height of `i`-th tower is `h_i`. Now
engineers want to choose the points where they should be mounted to get the maximal total power.
The landscape of a territory of the power plant is described by a polyline with `m` vertices. Vertices of
the landscape polyline have coordinates `(x_i,\ y_i)`, such that `x_i\ <\ x_{i+1}`.
The sun angle is always `α` degrees in Flatland. The sun is shining from
the top-left to the bottom-right.
The power that is produced by a tower depends on the length of its surface illuminated by the sun.
When two towers are mounted close to each other, the shadow of the left tower may fall onto the right
tower, so the power, produced by the right tower, decreases. Also, the landscape itself may contain high
points that drop shadows on some towers.
Your task is to find the points on the territory of the plant to mount the given towers to maximize the
total length of towers surface that is illuminated by the sun.
Input
The first line of the input file contains three integers `n`, `m` and `α` (`1\ ≤\ n\ ≤\ 10^4`, `2\ ≤\ m\ ≤\ 10^4`, `1\ ≤\ α\ <\ 90`).
The second line contains `n` integers `h_i` – the heights of the towers (`1\ ≤\ h_i\ ≤\ 10^3`). The following `m` lines
contain pairs `x_i,\ y_i` – the coordinates of the vertices of the landscape (`|x_i|\ ≤\ 10^5`, `x_i\ <\ x_{i+1}`, `|y_i|\ ≤\ 10^3`).
Output
On the first line output the maximal possible summary length of towers that can be illuminated by the
sun with an absolute precision of at least `10^{-6}`. On the next n lines output the x-coordinates of the
points where the towers should be mounted to achieve this maximum with an absolute precision of at
least `10^{-9}`. Towers should be listed in the same order they are given in the input file.
Sample Input
5 4 10
20 10 20 15 10
0 10
40 20
50 0
70 30
Sample Output
52.342888649592545
16.0
0.0
70.0
65.3
65.3
In this example two towers are mounted at the same point. This is allowed, but only one, the longest, of
the towers mounted at the same point is considered to be illuminated by the sun.
Source: ACM ICPC NEERC, 2013