#C4058. Eligible Houses for Decoration Competition
Eligible Houses for Decoration Competition
Eligible Houses for Decoration Competition
In this problem, you are given n houses arranged in a row, and each house has a certain height. A house (except the first and the last) is considered eligible for the decoration competition if both of its immediate neighbors are taller than it. More formally, for a house at position i (with 1-based indexing, where 2 ≤ i ≤ n-1), the house is eligible if:
\( H_{i-1} > H_i \) and \( H_{i+1} > H_i \)
Your task is to determine the number of eligible houses given the list of house heights.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer n — the number of houses.
- The second line contains n space-separated integers representing the heights of the houses.
Note: If n is less than 3, then there are no houses with two neighbors and the output should be 0.
outputFormat
Output a single integer — the number of eligible houses. The result should be printed to standard output (stdout).
## sample6
3 1 4 1 5 9
2