CF1463C Busy Robot

题目描述

### 题意翻译 你有一个机器人,初始位置($0$ 秒),它在数轴上的位置为 $0$。它的速度是 $1$ 单位每秒。 它会接收 $n$ 个命令:在第 $t_i$ 秒移动到 $x_i$ 。在它移动的时候,会忽视你的所有命令。 定义第 $i$ 个命令是成功的,当且仅当在第 $[t_i,t_{i+1}]$ 秒内机器人到达过 $x_i$ 。(我们定义 $t_{n+1}$ 为正无穷) 你的任务就是求出有多少条命令是成功的。

输入格式

第 $1$ 行, $1$ 个数 $t$ ,表示数据组数。 >每组数据的第 $1$ 行为 $n$ 。 > >接下来 $n$ 行,每行两个数 $t_i$ , $x_i$ 。

输出格式

$t$ 行,每行一个数,表示这组数据中成功的命令数量。 ### 数据规模与约定 $1 \leq t \leq 1000$ $1 \leq n \leq 10^5$ $1 \leq t_i \leq 10^9$ $-10^9 \leq x_i \leq 10^9$ 每组数据中 $n$ 的和不超过 $10^5$ 数据保证 $t_i$ 单调递增

说明/提示

The movements of the robot in the first test case are described in the problem statement. Only the last command is successful. In the second test case the second command is successful: the robot passes through target point $ 4 $ at time $ 5 $ . Also, the last command is eventually successful. In the third test case no command is successful, and the robot stops at $ -5 $ at time moment $ 7 $ . Here are the $ 0 $ -indexed sequences of the positions of the robot in each second for each testcase of the example. After the cut all the positions are equal to the last one: 1. $ [0, 0, 1, 2, 3, 4, 5, 4, 4, \dots] $ 2. $ [0, 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, \dots] $ 3. $ [0, 0, 0, -1, -2, -3, -4, -5, -5, \dots] $ 4. $ [0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 2, 2, 1, 0, 0, \dots] $ 5. $ [0, 0, 1, 0, -1, -2, -3, -4, -5, -6, -6, -6, -6, -7, -8, -9, -9, -9, -9, -8, -7, -6, -5, -4, -3, -2, -1, -1, \dots] $ 6. $ [0, 0, -1, -2, -3, -4, -4, -3, -2, -1, -1, \dots] $ 7. $ [0, 0, 1, 2, 2, \dots] $ 8. $ [0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -7, \dots] $