#P7839. Minimizing Flight Points

    ID: 21024 Type: Default 1000ms 256MiB

Minimizing Flight Points

Minimizing Flight Points

In this problem, there are n trees arranged in a line and numbered from 1 to n. Each tree i has a height h_i. Among these, m trees initially have nightingales who will perform a singing ball. The performance lasts for t time steps (numbered from 1 to t), and at the ith moment, a nightingale must be on a tree whose height satisfies

\( h > i \)

At each time step (starting from time 0 when the birds are on their initial trees), a nightingale may either:

  • Stay on the same tree, or
  • Move to an adjacent tree (i.e. from tree i to tree i-1 or i+1, if it exists).

However, if a nightingale is on a tree that is designated as a flight point, then in addition to the adjacent moves, she can teleport to any other flight point (provided the destination tree meets the height requirement at the next time step).

More formally, let the birds' positions be updated as follows. Let a state be represented by \( (k, j) \) meaning that at time \( k \) the bird is on tree \( j \). The following conditions must hold:

  • Initial state: \( (0, s) \) where \( s \) is one of the given starting positions.
  • For each time step \( k \) from 0 to \( t-1 \), if the bird is at tree \( j \) at time \( k \), then at time \( k+1 \) the bird may move to a tree \( j' \) if either:
  • \( |j' - j| \le 1 \) and \( h_{j'} > k+1 \), or
  • If \( j \) is a flight point and \( j' \) is also a flight point with \( h_{j'} > k+1 \).

The goal is to choose a subset of trees as flight points, so that every nightingale (starting from one of the given m trees) can follow a valid sequence of moves and complete the singing ball (i.e. reach time \( t \)). Since too many flight points make the ball chaotic, you must minimize the number of flight points.

Note: It is guaranteed that \( \max\{h_i\} > t \), so there is always at least one tree eligible at time \( t \).

inputFormat

The first line contains three integers: n, m, and t.

The second line contains n integers: h1, h2, ..., hn, where hi is the height of the ith tree.

The third line contains m integers representing the starting positions (tree indices) where the nightingales are initially located.

outputFormat

Output a single integer ― the minimum number of flight points needed so that every nightingale can complete the singing ball.

sample

5 2 3
2 4 3 5 3
1 5
0