## MLE '19 Contest 4 P9 - Poggers

View as PDF

Points: 7
Time limit: 2.0s
Memory limit: 512M

Author:
Problem type

An array of integers can be transformed into a new array through this process:

• is modified to be the maximum of and for all .

An array is stable if it remains the same after the above transformation is performed on the array. For example, is a stable array.

It can be proven that array , after a certain number of transformations, will result in a stable array. Can you print out the minimum number of transformations on array to transform it into a stable array?

#### Input Specification

The first line will contain the integer .

The second line will contain the array .

#### Output Specification

Output the number of minimum transformations to transform into a stable array.

#### Sample Input

5
1 3 2 4 5

#### Sample Output

4

• commented on Dec. 30, 2019, 3:38 p.m.

How can be modified to be the maximum of and ?

• commented on Dec. 31, 2019, 8:32 a.m.

is never modified. Note that the problem statement mentions that we only modify for .