#P11099. Maximizing Illuminated Area with Directional Lamps

    ID: 13156 Type: Default 1000ms 256MiB

Maximizing Illuminated Area with Directional Lamps

Maximizing Illuminated Area with Directional Lamps

There is a single point where several lamps are installed. Each lamp can be directed to illuminate a circular sector with a fixed radius \(R\) and a central angle \(\theta\) (in degrees). However, each lamp’s direction must be chosen from a given set of allowed directions (in degrees), and if the same direction is chosen more than once the overlapping area is only counted once.

When a lamp is directed with an allowed angle \(d\), it illuminates the angular interval \([d-\theta/2,\; d+\theta/2]\) (angles are measured in degrees and wrap around modulo 360). The overall illuminated area is defined as the area covered by the union of all the illuminated sectors. In other words, if the union of the angular intervals has a total measure of \(\phi\) degrees, then the area illuminated is given by:

[ A = \frac{\phi}{360} \cdot \pi R^2. ]

Your task is to decide, for each of the \(n\) lamps, which allowed direction to use (each lamp uses one allowed direction), in order to maximize \(\phi\) and thus maximize the illuminated area. Note that assigning the same direction to more than one lamp does not increase \(\phi\).

inputFormat

The input consists of three parts:

  1. The first line contains three space-separated values: an integer \(n\) (the number of lamps), a floating-point number \(R\) (the radius of each lamp’s illuminated sector), and a floating-point number \(\theta\) (the central angle in degrees of each lamp’s sector).
  2. The second line contains an integer \(m\), the number of allowed directions.
  3. The third line contains \(m\) space-separated integers representing the allowed directions (in degrees). Each allowed direction \(d\) means that a lamp aimed in that direction will illuminate the interval \([d-\theta/2,\; d+\theta/2]\), with angles taken modulo 360.

Constraints:

  • 1 \(\le\) \(n\) \(\le\) 10
  • 1 \(\le\) \(m\) \(\le\) 10
  • 0 \(\le\) each allowed direction \(d\) \( < 360\)
  • 0 \( < \theta \le 360\)
  • 0 \( < R \le 1000\)

outputFormat

Output a single floating-point number representing the maximum possible illuminated area. The answer is considered correct if its absolute or relative error does not exceed 1e-6.

sample

1 1 90
4
0 90 180 270
0.7853981634