P1091 [NOIP 2004 Senior] Chorus Formation
Description
$n$ students stand in a row. The music teacher will ask $n - k$ students to step out so that the remaining $k$ students form a "chorus formation."
A chorus formation is defined as follows: suppose the $k$ remaining students are numbered from left to right as $1, 2, \ldots, k$, and their heights are $t_1, t_2, \ldots, t_k$. They satisfy $t_1 < \cdots < t_i > t_{i+1} > \cdots > t_k \ (1 \le i \le k)$.
Your task is: given the heights of all $n$ students, compute the minimum number of students that must be removed so that the remaining students form a chorus formation.
Input Format
Two lines.
- The first line contains an integer $n$ ($2 \le n \le 100$), the total number of students.
- The second line contains $n$ integers separated by spaces. The $i$-th integer $t_i$ ($130 \le t_i \le 230$) is the height (in centimeters) of the $i$-th student.
Output Format
Output a single integer: the minimum number of students who must be removed.
Explanation/Hint
For 50% of the testdata, it is guaranteed that $n \le 20$.
For all the testdata, it is guaranteed that $n \le 100$.
Translated by ChatGPT 5