QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#13284. 最佳跑步者

الإحصائيات

体育场内有 $n$ 条跑道,长度分别为 $a_1, a_2, \dots, a_n$。此外还有 $m$ 名跑步者,第 $i$ 名跑步者从第 $b_i$ 条跑道的起点出发。

所有跑步者将进行 $T$ 秒的训练。跑步者的训练过程如下: 假设跑步者当前位于第 $i$ 条跑道的起点。他们会在 $a_i$ 秒内跑完当前跑道。之后,他们可以立即回到当前跑道的起点,或者移动到第 $(i - 1)$ 条跑道的起点(如果 $i > 1$),或者移动到第 $(i + 1)$ 条跑道的起点(如果 $i < n$)。此后,他们继续从移动到的跑道开始跑步。一旦训练时长达到 $T$ 秒,他们就结束训练。

我们定义“最佳跑步者”为在训练时间内跑完完整跑道次数最多的人(可能有多名这样的跑步者)。请确定最佳跑步者跑完的跑道数量。

输入格式

第一行包含三个整数 $n, m$ 和 $T$ ($1 \le m \le n \le 300\,000, 1 \le T \le 10^9$),分别表示跑道数量、跑步者数量和训练时长。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$),表示跑道的长度。

第三行包含 $m$ 个整数 $b_1, b_2, \dots, b_m$ ($1 \le b_1 < b_2 < \dots < b_m \le n$),表示跑步者出发的跑道编号。

输出格式

输出一个整数,表示其中一名跑步者在训练时间内能够跑完的最多完整跑道数量。

样例

样例输入 1

5 3 10
4 5 2 7 1
1 2 4

样例输出 1

4

样例输入 2

4 2 11
4 5 7 10
2 3

样例输出 2

2

说明

在第一个样例中,从第 4 条跑道出发的跑步者跑得最多:他们应该跑完第 4 条跑道,然后移动到第 5 条跑道并跑完 3 次。

在第二个样例中,从第 2 条跑道出发的跑步者可以跑完第 2 条跑道 2 次。

子任务

本题的测试点分为六组。只有通过某一组的所有测试点以及该组所要求的组别,才能获得该组的分数。

组别 分数 $n$ $T$ $a_i$ 所需组别 说明
0 0 样例
1 23 $n \le 1000$ 0
2 10 对所有 $1 \le i < n$,$a_i \le a_{i+1}$
3 16 $T \le 20$ 0
4 19 $a_i \le 20$ 0
5 11 $m = n$
6 21 0–5

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.