QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 64 MB 満点: 100

#13315. 出租车

統計

Byteasar 想要从 Bytehole 镇乘出租车前往距离 Bytehole $m$ 公里的 Bytepit 镇。在从 Bytehole 到 Bytepit 的路途中,距离 Bytehole $d$ 公里的地方有一个出租车基地,基地里有 $n$ 辆出租车,编号为 $1$ 到 $n$。第 $i$ 辆出租车的燃料足以行驶 $x_i$ 公里。

Byteasar 可以在任何地点更换出租车。所有的出租车最初都停在基地,但不需要返回基地。你的任务是确定 Byteasar 是否能从 Bytehole 到达 Bytepit,如果可以,求出完成这段旅程所需的最少出租车数量。

输入格式

标准输入的第一行包含三个整数 $m$、$d$ 和 $n$ ($1 \le d \le m \le 10^{18}$,$1 \le n \le 500\,000$),用空格分隔。它们分别表示:从 Bytehole 到 Bytepit 的距离、从 Bytehole 到出租车基地的距离,以及基地中出租车的数量。输入的第二行包含 $n$ 个整数 $x_1, x_2, \dots, x_n$ ($1 \le x_i \le 10^{18}$),用空格分隔。数字 $x_i$ 表示第 $i$ 辆出租车能行驶的最大距离(单位:公里)。

输出格式

你的程序应向标准输出打印一个整数:Byteasar 从 Bytehole 到达 Bytepit 所需的最少出租车数量。如果无法到达,程序应打印 0。

样例

输入 1

42 23 6
20 25 14 27 30 7

输出 1

4

说明

Byteasar 可以依次乘坐编号为 4、5、1 和 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.