Baltic OI '02 P3 - Triangles

View as PDF

Submit solution


Points: 12 (partial)
Time limit: 1.0s
Memory limit: 256M

Problem types
Baltic Olympiad in Informatics: 2002 Day 1, Problem 3

There are given n isosceles right triangles on a plane. Each triangle can be described by three integers x, y, m. Vertices of such a triangle are points which have coordinates (x, y), (x+m, y) and (x, y+m).

Write a program which calculates the total area covered by triangles.

Constraints

1 \le n \le 2\,000

|x_i|, |y_i| \le 10^7

1 \le m_i \le 1\,000

Input Specification

The first line of input contains one positive integer n, the number of triangles on a plane.

The next n lines describe the triangles, one triangle per line. Each line contains three space-separated integers x_i, y_i and m_i (1 \le i \le n).

Output Specification

Output one number with exactly one digit after the decimal point - the total area covered by triangles.

Sample Input

5
-5 -3 6
-1 -2 3
0 0 2
-2 2 1
-4 -1 2

Sample Output

24.5

Comments


  • 0
    d  commented on Nov. 25, 2022, 10:02 a.m.

    Forest Area is a similar problem with higher constraints.