#P6364. Celebration Oranges Distribution
Celebration Oranges Distribution
Celebration Oranges Distribution
Every year on Programmer's Day (1024), Black Horse Programmer organizes a grand celebration and distributes oranges to each class. In one class, there are \(n\) students standing in a row. The score of the \(i\)-th student is \(a_i\). The teacher wants to distribute oranges according to the students' previous exam scores, with the following conditions:
- Between any two adjacent students, the student with a higher score must receive more oranges.
- If two adjacent students have equal scores, they must receive the same number of oranges.
- Every student must receive at least one orange.
Due to budget constraints, the teacher wants to give out as few oranges as possible. Determine the minimum number of oranges required.
Note: All mathematical formulas must be written in \(\LaTeX\) format. For example, the score of the \(i\)-th student is \(a_i\).
inputFormat
The first line contains an integer \(n\), the number of students. The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\), representing the scores of the students in order.
outputFormat
Output a single integer representing the minimum number of oranges needed.
sample
3
1 2 2
5
</p>