我这次终于没有陷入以前的假算法了,hhh
但是被cin double卡成TLE也是难顶,以前看见别人代码写快读,我总是不屑一顾,要是想出正确算法还需要快读吸氧吗。
得,以后我也吸
题目描述:
Sandy likes to play with robots. He is going to organize a running competition between his robots. And he is going to give some presents to the winners. Robots are arranged in a line. They have their initial position (distance from the start line) and acceleration speed. These values might be different. When the competition starts, all robots move to the right with speed:
v ( t ) = a ∗ t v(t) = a * t v(t)=a∗t
Here a is acceleration speed and t is time from starting moment.
Now, the problem is that, how many robots can be the leader from the starting moment?
Here leader means the unique rightmost robot from the start line at some moment. That is, at some specific time, if a robot is rightmost and unique then it is the leading robot at that time. There can be robots with same initial position and same acceleration speed.
The runway is so long that you can assume there’s no finish line.
样例
input | output |
---|---|
1 3 1 1 2 3 3 2 |
2 |
分析
对任意robot i,在时间 t t t时的位置坐标:
f ( i , t ) = p i + a t 2 2 f(i, t) = p_i + \frac{at^2}{2} f(i,t)=pi+2at2
如果要robot i,有机会当第一,则
p i + a i t 2 2 > p j + a j t 2 2 p_i + \frac{a_it^2}{2} > p_j + \frac{a_jt^2}{2} pi+2ait2