QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#6773. 真实故事

Statistiques

成都双流国际机场是服务于中国四川省省会成都的主要国际机场。2019 年,该机场旅客吞吐量达到 5590 万人次,位列 2019 年全球最繁忙机场前 25 名,是中国大陆第四繁忙、中国西部最繁忙的机场。

Ema 和她的朋友们快要赶不上飞机了。现在是第 0 小时开始,他们距离机场 $x$ km,登机时间是第 $p_0$ 小时开始。总共有 $n$ 个人(包括 Ema 自己),第 $i$ 个人以 $s_i$ km/h 的速度行进。他们必须在登机时间之前(含登机时间)到达机场才能赶上飞机。

然而,事情还有转机。Ema 知道登机时间会被推迟。登机时间总共会被推迟 $k$ 次:第 $i$ 次推迟会在第 $t_i$ 小时开始时宣布,并将登机时间推迟到第 $p_i$ 小时开始。不过,挑战依然存在,因为每个人只有在能及时赶上飞机时才会行动。也就是说,如果当前距离登机还有一段时间,但不足以让他/她到达机场,他/她就会停止移动并停留在当前位置;否则,他/她将从停止的地方继续移动,或者保持移动状态。

注意,每次登机时间被推迟时,每个人都会立即相应地改变他们的行动。此外,每个人只有在推迟宣布时才知道这一消息,无法提前采取行动。

请计算最终有多少人能赶上飞机。

输入格式

每个测试文件中仅包含一组测试数据。

第一行包含四个整数 $n, k, x$ 和 $p_0$ ($1 \le n, k \le 10^5, 1 \le x, p_0 \le 10^9$),分别表示人数、推迟次数、从起点到机场的距离以及初始登机时间。

第二行包含 $n$ 个整数 $s_1, s_2, \dots, s_n$ ($1 \le s_i \le 10^9$),表示第 $i$ 个人的速度。

第三行包含 $k$ 个整数 $t_1, t_2, \dots, t_k$ ($1 \le t_i \le 10^9, t_i < t_{i+1}, t_i < p_{i-1}$),表示第 $i$ 次推迟宣布的时间。

第四行包含 $k$ 个整数 $p_1, p_2, \dots, p_k$ ($1 \le p_i \le 10^9, p_i < p_{i+1}$),表示第 $i$ 次宣布后登机时间被推迟到的时间。

输出格式

输出一行,包含一个整数,表示最终能赶上飞机的人数。

样例

样例输入 1

4 3 10 4
1 5 2 1
3 4 5
7 9 10

样例输出 1

2

样例输入 2

1 3 10 3
1
2 3 4
5 8 10

样例输出 2

0

说明

对于第一个样例,在第 0 小时开始时,只有速度为 $5\,\text{km/h}$ 的人开始移动,并在第 2 小时开始时到达机场。随后在第 4 小时开始时,速度为 $2\,\text{km/h}$ 的人也开始移动,并在第 9 小时开始时到达机场。只有这两个人能赶上飞机,其余两人从未移动,因为三次推迟均无法让他们及时到达。

对于第二个样例,唯一的那个人从未移动。如果他从一开始就出发,他本可以赶上飞机,但他选择了放弃。这个故事告诉我们,并非所有的努力都能带来成功,但放弃一定会导致失败。

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.