assume you provide three orders to the robot: at time 1 maneuver to point 5, at time 3 move to point 0 and at time 6 move to point 4. Then, at that point, the robot remains at 0 until time 1, then, at that point, begins moving towards 5, overlooks the subsequent order, arrives at 5 at time 6 and quickly begins moving to 4 to execute the third order. At time 7 it arrives at 4 and stops there.
Correct answer will be upvoted else Multiple Downvoted. Computer science.
assume you provide three orders to the robot: at time 1 maneuver to point 5, at time 3 move to point 0 and at time 6 move to point 4. Then, at that point, the robot remains at 0 until time 1, then, at that point, begins moving towards 5, overlooks the subsequent order, arrives at 5 at time 6 and quickly begins moving to 4 to execute the third order. At time 7 it arrives at 4 and stops there.
You call the order I fruitful, in case there is a period second in the reach [ti,ti+1] (I. e. after you provide this order and before you give another, the two limits comprehensive; we consider tn+1=+∞) when the robot is at point xi. Count the number of fruitful orders. Note that it is conceivable that a disregarded order is fruitful.
Input
The principal line contains a solitary integer t (1≤t≤1000) — the number of experiments. The following lines depict the experiments.
The principal line of an experiment contains a solitary integer n (1≤n≤105) — the number of orders.
The following n lines depict the orders. The I-th of these lines contains two integers ti and xi (1≤ti≤109, −109≤xi≤109) — the time and the place of the I-th order.
The orders are requested by time, that is, ti<ti+1 for all conceivable I.
The amount of n over experiments doesn't surpass 105.
Output
For each testcase output a solitary integer — the number of fruitful orders.
Step by step
Solved in 4 steps with 1 images