Electric Scooter

hard
A ride-sharing company has $n$ electric scooters available for a new rental service. You are given two $0$-indexed integer arrays, $\texttt{startCosts}$ and $\texttt{chargeCosts}$, both of length $n$. The $i^{th}$ scooter requires $\texttt{startCosts}[i]$ units of battery charge to start and consumes $\texttt{chargeCosts}[i]$ units of battery per kilometer traveled. You are also given an integer $\texttt{batteryLimit}$ representing the maximum available battery charge for the operation.

When using a consecutive segment of $k$ scooters, the total battery consumption is calculated as $\max(\texttt{startCosts}) + k \times \sum(\texttt{chargeCosts})$, where $\max(\texttt{startCosts})$ is the highest startup charge among the $k$ scooters and $\sum(\texttt{chargeCosts})$ is the total battery consumption of all $k$ scooters per kilometer.

Return the maximum number of consecutive scooters you can deploy such that the total battery consumption does not exceed $\texttt{batteryLimit}$.

Input Format:

The first line of input contains three integers $n$ $(1 \leq n \leq 10^5)$ denoting the size of $\texttt{startCosts}$ and $\texttt{chargeCosts}$ and $b$ $(1 \leq b \leq 10^{15})$ denoting $\texttt{batteryLimit}$.

The second line contains $n$ integers $s_1, s_2, \dots, s_n$ representing $\texttt{startCosts}$. $(1 \leq s_i \leq 10^5)$

The third line contains $n$ integers $c_1, c_2, \dots, c_n$ representing $\texttt{chargeCosts}$. $(1 \leq c_i \leq 10^5)$

Output Format:

Give a single integer representing the answer.

Examples:

Example 1:

Input:

5 25
3 6 1 3 4
2 1 3 4 5

Output:

3

Example 2:

Input:

3 19
11 12 19
10 8 7

Output:

0

Code

Loading Editor...