QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 2048 MB Puntuación total: 100

#3861. 米兰德比

Estadísticas

米兰和国际米兰之间的德比战即将开始,你被选为这场比赛的助理裁判,也就是边裁。你的任务是沿着边线(即球场的一侧)移动,时刻仔细观察比赛,以检查越位位置和其他犯规。

在意大利,足球是一件极其严肃的事情,因此尽可能长时间地密切关注球的动向至关重要。这意味着你希望最大化你所能密切观察到的踢球次数。如果你在踢球发生时,处于沿边线距离踢球发生地点最近的位置,你就能密切观察到该次踢球。

幸运的是,专家分析师已经能够准确预测比赛中将发生的所有踢球。也就是说,你已经得到了两组整数 $t_1, \dots, t_n$ 和 $a_1, \dots, a_n$,表示在比赛开始 $t_i$ 秒后,球将被踢出,如果你在沿边线的位置 $a_i$ 处,你就可以密切观察到这次踢球。

比赛开始时,你从位置 $0$ 出发,你沿着边线行走的最大速度为 $v$ 单位每秒(即你每秒最多可以改变 $v$ 个单位的位置)。你最多能密切观察到多少次踢球?

输入格式

第一行包含两个整数 $n$ 和 $v$ ($1 \le n \le 2 \cdot 10^5$, $1 \le v \le 10^6$),表示将要发生的踢球次数和你的最大速度。

第二行包含 $n$ 个整数 $t_1, \dots, t_n$ ($1 \le t_i \le 10^9$),表示比赛中踢球发生的时间。保证时间序列严格递增,即 $t_1 < t_2 < \dots < t_n$。

第三行包含 $n$ 个整数 $a_1, \dots, a_n$ ($-10^9 \le a_i \le 10^9$),表示你必须到达的沿边线位置,才能密切观察到每次踢球。

输出格式

输出你能密切观察到的最大踢球次数。

样例

样例输入 1

3 2
5 10 15
7 17 29

样例输出 1

2

说明

样例 1 的解释: 可以在前 3.5 秒以最大速度向右移动,并停留在位置 7 直到第一次踢球发生,然后立即以最大速度向右移动,在位置 17 观察第二次踢球。在第二次踢球之后,没有办法密切观察第三次踢球,因此最多只能观察到 2 次踢球。

样例输入 2

5 1
5 7 8 11 13
3 3 -2 -2 4

样例输出 2

3

样例输入 3

1 2
3
7

样例输出 3

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.