시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 28 6 5 33.333%

문제

시장은 새로운 TV 송신 시스템을 도입하기로 했다. 도시는 길이가 D인 선분 위에 여러 개의 빌딩이 놓여져 있는 형태이다. 빌딩의 너비는 무시할 수 있을만큼 작다. 일부 빌딩의 옥상에는 TV 송신기 있으며, 그 크기도 무시할 수 있다.

TV 송신기는 TV 신호를 모든 방향으로 전송한다. 신호는 직선으로 전송되며, 빌딩을 통과할 수 없다. 도시의 일부분은 기존에 설치된 송신기로 TV 신호를 수신할 수 있다.

TV 신호를 받을 수 있는 선분을 찾고 그 길이를 출력하는 프로그램을 작성하시오.

입력

첫째 줄에 빌딩의 수 N (1 ≤ N ≤ 3·105)과 도시의 길이 D(1 ≤ D ≤ 109)가 주어진다.

다음 N개 줄에는 i번째 빌딩의 정보를 나타내는 세 개의 정수가 주어진다.

  1. 빌딩의 옥상에 송신기가 설치된 경우에 첫 번째 정수는 1이고, 설치되지 않은 경우에는 0이다.
  2. 두 번째 정수는 빌딩이 도시의 왼쪽 끝으로부터 떨어진 거리 Xi (0 ≤ Xi ≤ D) 이다.
  3. 세 번째 정수는 빌딩의 높이 Hi (1 ≤ Hi ≤ 109) 이다.

빌딩은 왼쪽으로부터 떨어진 거리가 증가하는 순으로 주어진다. 두 빌딩이 같은 곳에 있는 경우는 없다.

출력

첫째 줄에 구한 정답을 출력한다. 오차는 최대 10-3까지 허용된다.

예제 입력 1

5 15
0 4 3
1 5 5
1 6 6
0 9 2
0 10 3

예제 출력 1

8.500000

힌트

문제의 그림에서 X축이 굵은선으로 되어있는 부분은 TV 신호를 받을 수 없는 곳이다.

W3sicHJvYmxlbV9pZCI6Ijk2MzAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJUViBcdWMxYTFcdWMyZTBcdWFlMzAiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzJkY1x1YzdhNVx1Yzc0MCBcdWMwYzhcdWI4NWNcdWM2YjQgVFY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