#P12078. [OOI 2025] Best Runner

[OOI 2025] Best Runner

题目描述

There are nn running tracks in the stadium with lengths a1a_1, a2a_2, \ldots, ana_n. There are also mm runners, with the ii-th runner starting at the beginning of track bib_i.

All runners will train for TT seconds. The training of a runner proceeds as follows:

Let the runner currently be at the beginning of track ii. They will run to the end of the current track in aia_i seconds. After that, they can either instantly return to the beginning of the current track, or move to the beginning of track (i1)(i - 1) (if i>1i > 1), or to the beginning of track (i+1)(i + 1) (if i<ni < n). After this, they continue running from the track they moved to. Once the training duration reaches TT seconds, they finish their training.

We define the best runner as the one who runs the most number of full\textbf{full} tracks during the training time (there may be several such runners). Determine how many tracks the best runner will run.

输入格式

The first line contains three integers nn, mm, and TT (1mn3000001 \le m \le n \le 300\,000, 1T1091 \le T \le 10^9) --- the number of tracks, the number of runners, and the duration of the training.

The second line contains nn integers a1a_1, a2a_2, \ldots, ana_n (1ai1091 \le a_i \le 10^9) --- the lengths of the tracks.

The third line contains mm integers b1b_1, b2b_2, \ldots, bmb_m (1b1<b2<<bmn1 \le b_1 < b_2 < \ldots < b_m \le n) --- the track numbers from which the runners start.

输出格式

Output a single integer --- the maximum number of full tracks that one of the runners can run during the training time.

5 3 10
4 5 2 7 1
1 2 4
4
4 2 11
4 5 7 10
2 3
2

提示

Note

In the first example, the runner starting on track 44 can run the most tracks: they should run track 44, then move to track 55 and run it 33 times.

In the second example, the runner starting on track 22 can run the second track 22 times.

Scoring

The tests for this problem consist of six groups. Points for each group are given only if all tests of the group and all tests of the required groups are passed.

Group Points Additional constraints: nn TT aia_i Required Groups Comment
0 -- -- -- -- Examples.
1 23 n1000n \le 1000 0
2 10 -- -- aiai+1a_i \le a_{i + 1} for all 1i<n1 \le i < n
3 16 T20T \le 20 0
4 19 -- ai20a_i \le 20
5 11 -- -- m=nm = n
6 21 0 -- 5