#P10579. [蓝桥杯 2024 国 A] 最长子段

[蓝桥杯 2024 国 A] 最长子段

Problem Description

Given a sequence (s1,s2,,sn)(s_1, s_2, \cdots, s_n) of length nn and three numbers a,b,ca, b, c, you need to find a pair L,RL, R that satisfies:

$$\sum\limits_{i=L}^R s_i > a(bR - cL), \quad 1 \le L \le R \le n$$

That is, the sum of terms from the LL-th to the RR-th in the sequence is greater than a(bRcL)a \cdot (b \cdot R - c \cdot L). Among all L,RL, R that satisfy the condition, find the maximum value of RL+1R - L + 1.

The testdata guarantees that such a pair LL and RR exists.

Input Format

The first line contains four integers n,a,b,cn, a, b, c, separated by single spaces.

The second line contains nn integers s1,s2,,sns_1, s_2, \cdots, s_n, separated by single spaces.

Output Format

Output one line containing one integer, which is the answer.

4 1 5 6
1 2 3 4
3

Hint

For 60%60\% of the test cases, n5000n \le 5000.
For all test cases, 1n3×1051 \le n \le 3 \times 10^5, 1a,b,c10001 \le a, b, c \le 1000, and si109|s_i| \le 10^9.

Translated by ChatGPT 5