QOJ.ac

QOJ

时间限制: 3 s 内存限制: 128 MB 总分: 100

#12298. 望远镜

统计

Byteasar 今晚打算观看一场流星雨。他已经阅读了流星雨路径的精确预报。他知道这场流星雨将由 $n$ 颗流星组成,第 $i$ 颗流星将在午夜后第 $t_i$ 秒出现,即它在 $t_i - 1$ 到 $t_i$ 这段时间内可见。对于每一颗流星,Byteasar 只对在它整个可见期间进行观测感兴趣。

Byteasar 将在一座附近的小山上观测天空。他不会用肉眼观测。山上有一台非常适合业余爱好者使用的望远镜。然而,使用它是要收费的。望远镜接受硬币。每投入价值为 $c$ 的硬币,它允许观测天空恰好 $c$ 秒。遗憾的是,这台望远镜有些破旧,因此投入一枚硬币后,必须等待 $r$ 秒才能看到任何东西。每次只能投入一枚硬币。因此,如果你投入了一枚价值为 $c$ 的硬币,下一枚硬币只有在至少 $r + c$ 秒后才能被接受。

Byteasar 的口袋里有 $m$ 枚硬币,面值分别为 $c_1, \ldots, c_m$。他打算用这些硬币支付望远镜的费用。他想知道他最多能用这台望远镜观测到多少颗流星。

输入格式

输入的第一行包含三个整数 $n$、$m$ 和 $r$ ($1 \le n \le 100$, $1 \le m \le 10$, $1 \le r \le 10^8$)。第二行包含 $n$ 个整数 $t_1, \ldots, t_n$,按递增顺序给出 ($1 \le t_i \le 10^8$)。第三行包含 $m$ 个整数 $c_1, \ldots, c_m$ ($1 \le c_i \le 10^8$)。

输出格式

输出仅一行,包含一个整数,即 Byteasar 用望远镜能观测到的流星的最大数量。

样例

输入 1

7 3 2
1 3 6 7 8 12 13
2 5 1

输出 1

6

在上图中,黑色矩形表示流星可见的秒数。如果 Byteasar 想观测 6 颗流星,他应该分别在时刻 -2、2 和 9 投入硬币,投入的硬币面值顺序为 1、5 和 2。

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.