CF832C.Strange Radiation

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

nn people are standing on a coordinate axis in points with positive integer coordinates strictly less than 10610^{6} . For each person we know in which direction (left or right) he is facing, and his maximum speed.

You can put a bomb in some point with non-negative integer coordinate, and blow it up. At this moment all people will start running with their maximum speed in the direction they are facing. Also, two strange rays will start propagating from the bomb with speed ss : one to the right, and one to the left. Of course, the speed ss is strictly greater than people's maximum speed.

The rays are strange because if at any moment the position and the direction of movement of some ray and some person coincide, then the speed of the person immediately increases by the speed of the ray.

You need to place the bomb is such a point that the minimum time moment in which there is a person that has run through point 00 , and there is a person that has run through point 10610^{6} , is as small as possible. In other words, find the minimum time moment tt such that there is a point you can place the bomb to so that at time moment tt some person has run through 00 , and some person has run through point 10610^{6} .

输入格式

The first line contains two integers nn and ss ( 2<=n<=1052<=n<=10^{5} , 2<=s<=1062<=s<=10^{6} ) — the number of people and the rays' speed.

The next nn lines contain the description of people. The ii -th of these lines contains three integers xix_{i} , viv_{i} and tit_{i} ( 0<x_{i}<10^{6} , 1<=v_{i}<s , 1<=ti<=21<=t_{i}<=2 ) — the coordinate of the ii -th person on the line, his maximum speed and the direction he will run to ( 11 is to the left, i.e. in the direction of coordinate decrease, 22 is to the right, i.e. in the direction of coordinate increase), respectively.

It is guaranteed that the points 00 and 10610^{6} will be reached independently of the bomb's position.

输出格式

Print the minimum time needed for both points 00 and 10610^{6} to be reached.

Your answer is considered correct if its absolute or relative error doesn't exceed 10610^{-6} . Namely, if your answer is aa , and the jury's answer is bb , then your answer is accepted, if .

输入输出样例

  • 输入#1

    2 999
    400000 1 2
    500000 1 1
    

    输出#1

    500000.000000000000000000000000000000
    
  • 输入#2

    2 1000
    400000 500 1
    600000 500 2
    

    输出#2

    400.000000000000000000000000000000
    

说明/提示

In the first example, it is optimal to place the bomb at a point with a coordinate of 400000400000 . Then at time 00 , the speed of the first person becomes 10001000 and he reaches the point 10610^{6} at the time 600600 . The bomb will not affect on the second person, and he will reach the 00 point at the time 500000500000 .

In the second example, it is optimal to place the bomb at the point 500000500000 . The rays will catch up with both people at the time 200200 . At this time moment, the first is at the point with a coordinate of 300000300000 , and the second is at the point with a coordinate of 700000700000 . Their speed will become 15001500 and at the time 400400 they will simultaneously run through points 00 and 10610^{6} .

首页