QOJ.ac

QOJ

时间限制: 3 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#6369. 青蛙跳跃

统计

Marichka 和 Zenyk 喜欢浪漫的夜晚。今天他们决定观看青蛙跳石头。

有 $n$ 块石头排成一行,从左到右依次编号为 $1$ 到 $n$。任意两块相邻石头之间的距离恰好为 $1$ 米。

此外还有 $m$ 只青蛙,最初都位于第一块石头上。目标是将所有青蛙通过跳跃移动到最后一块(第 $n$ 块)石头上。每只青蛙只能向前跳。

必须满足以下两个条件: 1. 石头 $a_1, a_2, \dots, a_k$ 必须恰好被其中一只青蛙访问过一次。 2. 所有其他石头(第一块和最后一块除外)绝不能被任何青蛙访问。

当第 $i$ 只青蛙单次跳跃距离超过 $d$ 米时,会消耗 $c_i$ 点能量。跳跃距离不超过 $d$ 米则不消耗能量。

你的任务是求出所有青蛙到达最后一块石头所需消耗的总能量的最小值。

输入格式

第一行包含四个空格分隔的整数 $n, m, k$ 和 $d$ ($3 \le n \le 10^9$, $1 \le m, k \le 10^5$, $1 \le d \le 10^9$)。第二行包含 $m$ 个空格分隔的整数 $c_i$,表示对应青蛙进行大跳跃所需的能量消耗 ($1 \le c_i \le 10^9$)。第三行包含 $k$ 个空格分隔的互不相同的整数 $a_i$,表示必须被恰好访问一次的石头的编号 ($2 \le a_i < n$)。

输出格式

输出一行,包含一个整数,表示最小总能量消耗。

样例

样例输入 1

10 2 3 3
4 7
4 8 7

样例输出 1

4

样例输入 2

10 2 2 3
4 7
9 5

样例输出 2

15

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.