PivotOJ

ODAŠILJAČI

시간 제한: 1000ms메모리 제한: 128MB출처: COCI 2013-2014BOJ 9630

문제

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 D on which there are buildings of different heights. The width of a building is negligible. On top of some buildings, television transmitters are set, their dimensions are also negligible. 

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. 

입력

The first line of input contains the integer N (1 ≤ N ≤ 3·105), the number of buildings, and the integer D (1 ≤ D ≤ 109), the city length. 

Each of the following N lines contains three numbers which describe the ith building: 

  1. a number which determines whether there is a transmitter on top of the building: 0 (no) or 1 (yes) 
  2. an integer Xi (0 ≤ Xi ≤ D), the distance between the building and the left end of the city 
  3. an integer Hi (1 ≤ Hi ≤ 109), the building 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. 

출력

The first and only line of output must contain the required length from the text. 

Note: the maximum permissible deviation from the official solution is 10-3

힌트

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.

예제

예제 1

입력
3 10
1 2 6
0 4 3
0 8 2
출력
6.000000

예제 2

입력
5 15
0 4 3
1 5 5
1 6 6
0 9 2
0 10 3
출력
8.500000
코드를 제출하려면 로그인하세요.