#ABC475C. 沿线行走 / Walk the Line

沿线行走 / Walk the Line

Problem Statement

There are NN towns arranged in a line. The towns are numbered 1,2,…,N1, 2, \ldots, N, and for each integer ii satisfying 1≤i≤N−11 \leq i \leq N-1, town ii and town i+1i + 1 are connected by a road of length AiA_i.

You are initially at town SS. You can repeatedly move between two towns connected by a road using that road.

Find the maximum possible number of towns visited in a sequence of moves such that the total distance traveled is at most LL. Here, town SS is included among the towns visited, and a town visited multiple times is counted only once.

Constraints

  • 2≤N≤80002 \leq N \leq 8000
  • 1≤S≤N1 \leq S \leq N
  • 0≤L≤10180 \leq L \leq 10^{18}
  • 1≤Ai≤1091 \leq A_i \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN SS LL
  • A1A_1 A2A_2 …\ldots AN−1A_{N - 1}

Output

Output the answer.

6 3 10
5 2 4 1 6
4

You are initially at town 33. If you move in the order town 3→2→3→4→53 \to 2 \to 3 \to 4 \to 5, the total distance traveled is 2+2+4+1=92 + 2 + 4 + 1 = 9, and the towns visited are 2,3,4,52, 3, 4, 5, that is, four towns.

It is impossible to visit five or more towns with a total travel distance of at most 1010, so the answer for this case is 44.

8 8 17
2 3 4 4 3 5 1
6
2 1 1000000000000000000
10000
2
9 6 28
5 4 9 2 3 6 1 4
6