#P8226. Maximizing Cherry Barrier Activations

    ID: 21405 Type: Default 1000ms 256MiB

Maximizing Cherry Barrier Activations

Maximizing Cherry Barrier Activations

In this problem, Reimu starts her journey with a variable (c) storing the current number of cherry points, initially (0). Whenever (c) becomes exactly (k) at any moment, she immediately activates the Cherry Barrier and resets (c) to (0).

The path is divided into (n) consecutive levels. In the (i)-th level, if Reimu does not use a bomb, she collects (a_i) cherry points which are uniformly distributed along the level. That is, as she traverses the level, she increases (c) by (1) each time. Note that if at any moment during collection, (c) reaches exactly (k), the barrier activates immediately and (c) is reset to (0), after which she continues collecting the remaining points in that level.

Reimu has (m) specific requirements. The (i)-th requirement is denoted by (b_i), meaning that she wants the barrier to be activated exactly when the (b_i)-th level finishes. If the barrier is activated in the middle of a level but not exactly at the end, the requirement is not considered fulfilled.

Additionally, Reimu can use a bomb at the beginning of exactly one level (or choose not to use one) to completely skip the collection of that level’s cherry points. When a level is skipped, (c) remains unchanged and no barrier activation occurs in that level.

Your task is to compute the maximum number of requirements that can be fulfilled if Reimu optimally chooses whether to use the bomb and at which level to use it.

All mathematical formulas must be presented in (\LaTeX) format.

inputFormat

The first line contains three integers (n), (k), and (m) ( (1 \leq n \leq 10^5,; 1 \leq k \leq 10^5, ; 0 \leq m \leq n)), representing the number of levels, the threshold for barrier activation, and the number of requirements respectively.

The second line contains (n) non-negative integers (a_1, a_2, \dots, a_n) where (a_i) denotes the number of cherry points available in the (i)-th level. It is guaranteed that (0 \leq a_i \leq 10^5).

The third line contains (m) distinct integers (b_1, b_2, \dots, b_m) ((1 \leq b_i \leq n)), indicating that Reimu wants the barrier to be activated exactly at the moment the (b_i)-th level ends.

outputFormat

Output a single integer: the maximum number of requirements that can be fulfilled.

sample

4 5 3
2 0 3 1
1 3 4
1