The mayor has decided that it is high time to implement a new system of television transmitters. The city can be represented as a segment of the length
Television transmitters emit a television signal in all directions around them. The signal is spread through space in straight lines and cannot pass through buildings. A certain point in the city is considered covered if it is reached by a signal from an existing transmitter.
Find the segment of the city covered by television signal and output its length.
Input Specification
The first line of input contains the integer
Each of the following
- A number which determines whether there is a transmitter on top of the building:
0
(no) or1
(yes). - An integer
, the distance between the building and the left end of the city. - An integer
, the building's height.
The buildings are sorted in ascending order by the distance from the left end of the city. No two buildings will be located on the same distance from the left end of the city.
Output Specification
The first and only line of output must contain the required length from the text.
Please Note: the maximum permissible deviation from the official solution is
Scoring
In test cases worth
Sample Input 1
3 10
1 2 6
0 4 3
0 8 2
Sample Output 1
6.000000
Sample Input 2
5 15
0 4 3
1 5 5
1 6 6
0 9 2
0 10 3
Sample Output 2
8.500000
Explanation for Sample Output 2
This example corresponds to the image from the text. The image depicts the city. The buildings are marked with vertical lines, and the transmitters with circles on the tops of the buildings. The bold lines on the x-axis represent the segment of the city not covered by television signal.
Comments