#P10579. Maximal Subarray Length with Weighted Bound

    ID: 12600 Type: Default 1000ms 256MiB

Maximal Subarray Length with Weighted Bound

Maximal Subarray Length with Weighted Bound

Given a sequence \( (s_1, s_2, \dots, s_n) \) and three numbers \( a, b, c \), find a pair of indices \( L, R \) (with \( 1 \le L \le R \le n \)) such that

\[ \sum_{i=L}^{R} s_i > a\cdot (bR - cL), \]

It is guaranteed that there exists at least one such pair. Among all such pairs, output the maximum possible value of \( R - L + 1 \), which is the length of the corresponding subarray.

inputFormat

The first line contains four integers \( n, a, b, c \) where \( n \) is the length of the sequence, and \( a, b, c \) are given numbers.

The second line contains \( n \) integers \( s_1, s_2, \dots, s_n \) representing the sequence.

outputFormat

Output a single integer representing the maximum length of the subarray \( [L, R] \) such that \( \sum_{i=L}^{R} s_i > a\cdot (bR - cL) \).

sample

5 1 2 3
1 2 3 4 5
5