#P7762. Union of Centered Rectangles

    ID: 20949 Type: Default 1000ms 256MiB

Union of Centered Rectangles

Union of Centered Rectangles

Given \( N \) rectangles whose geometric centers are at the origin in the 2D Cartesian coordinate system. For each rectangle with width \( w \) and height \( h \), its sides are parallel to the axes, covering the region \( \left[-\frac{w}{2},\frac{w}{2}\right] \times \left[-\frac{h}{2},\frac{h}{2}\right] \).

The task is to compute the total area covered by at least one rectangle (i.e. the union of all these rectangles).

inputFormat

The first line contains a positive integer \( N \) representing the number of rectangles. Each of the following \( N \) lines contains two integers \( w \) and \( h \) (\( 1 \leq w, h \leq 10^9 \)), denoting the width and height of a rectangle, respectively.

outputFormat

Output a single number: the total colored area (i.e., the union area of the given rectangles). If the answer is an integer, output it as an integer; otherwise, output it as a floating-point number.

sample

1
4 6
24