București, Steaua București

Time limit: 1s Memory limit: 512MB Input: Output:

Task

Steaua București is the team with the greatest achievements in the history of Romanian football.

It has had incredible seasons. For example, in 19861986, it managed to win the UEFA Champions League.

In 20242024, the team won the Romanian Championship, and the staff organized a celebration.

After a few hours of fun, the coaches Elias and Mihai started thinking about interesting statistics from the team's history.

The two were analyzing the list of the team's points at the end of each season over the past NN years.
Then, Mihai posed the following problem to Elias:

We define a change of maximum as the appearance of a value greater than all previously encountered values. If we are at the first value, then this property is automatically fulfilled.

The question is: Given the list of the team's points at the end of each season over the past NN years, what is the longest continuous sequence of values among these NN with exactly K1K_1 changes of maximum when traversing the values from left to right and exactly K2K_2 changes of maximum when traversing the values from right to left?

Since the celebration was a great success, coaches Mihai and Elias cannot solve the problem on their own, so they are asking for your help.

Input data

The first line contains the numbers NN, K1K_1, and K2K_2, separated by a space.

The second line contains an array AA of length NN, representing the scores at the end of each season over the past NN years, in chronological order, separated by a space.

Output data

The output contains the length of the longest continuous sequence with the property described in the statement if there is at least one, or 1-1 otherwise.

Constraints and clarifications

  • 1N1 000 0001 \leq N \leq 1 \ 000 \ 000;
  • 1K1,K2N1 \leq K_1, K_2 \leq N;
  • 1AiN,(1iN)1 \leq A_i \leq N, (1 \leq i \leq N).
# Score Restrictions
1 20 1N5001 \leq N \leq 500
2 25 501N2 000501 \leq N \leq 2 \ 000
3 30 AiAj,(1i<jN)A_i \neq A_j, (1\leq i < j \leq N)
4 25 No additional restrictions

Example

stdin

12 3 5
1 3 1 2 1 3 4 5 4 3 2 1

stdout

11

Explanation

There are 22 sequences where there are exactly 33 changes of maximum from left to right and exactly 55 changes of maximum from right to left: (2,12)(2, 12), (6,12)(6, 12). The longest among them is (2,12)(2, 12), having a length of 1111.

Log in or sign up to be able to send submissions!