#P11021. 「LAOI-6」区间测速

    ID: 10240 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学贪心二分洛谷原创O2优化洛谷月赛

「LAOI-6」区间测速

Description

Little A is driving on a straight highway (can make U-turns instantly, ignoring time and distance), abstracted as a number line.

You are given information from nn surveillance records. The ii-th record indicates Little A was at coordinate xix_i at time tit_i.

There are mm queries. The ii-th query provides uiu_i and viv_i: if the time of the uiu_i-th record is temporarily changed to viv_i, what is the minimal possible value of the maximum speed (floor to integer) in any valid driving path? Queries are independent; modifications are reverted after each query.

Formal Description

Given nn, mm, arrays xx, and tt of length nn. For each of mm independent modifications (changing tuit_{u_i} to viv_i), compute:

$$\left\lfloor \max_{1 \le i < j \le n} \frac{|x_i - x_j|}{|t_i - t_j|} \right\rfloor$$

Input Format

First line: Two integers nn, mm.

Next nn lines: Two integers xix_i, tit_i.

Next mm lines: Two integers uiu_i, viv_i.

Output Format

For each query, output the floor of the maximum speed.

5 3
10 3
-10 1
0 5
-5 0
10 7
1 2
2 2
3 100
20
20
10

Hint

Sample Explanation

After the first query:

  • Little A's positions: (5,0)(-5, 0), (10,1)(-10, 1), (10,2)(10, 2), (0,5)(0, 5), (10,7)(10, 7).
  • The minimal maximum speed is 2020 (from t=1t=1 to t=2t=2, moving 10-10 to 1010).

Constraints:

  • 2n1052 \leq n \leq 10^5, 1m1051 \leq m \leq 10^5.
  • 109xi109-10^9 \leq x_i \leq 10^9, 0ti,vi1090 \leq t_i, v_i \leq 10^9.
  • 1uin1 \leq u_i \leq n.
  • All tit_i (after modifications) are distinct.

Test Cases

Test Case Special Properties
1~3 n,m103n, m \leq 10^3
4~5 105xi105-10^5 \leq x_i \leq 10^5
6~7 m100m \leq 100
8~10 None