#P1823. [COI 2007] Patrik 音乐会的等待
[COI 2007] Patrik 音乐会的等待
Description
people are standing in a queue to enter a concert. People are bored, so they start turning around to look for their acquaintances in the line.
For any two people and in the queue, they can see each other if they are adjacent, or if there is no one between them who is taller than both and .
Write a program to compute how many pairs of people can see each other.
Input Format
The first line contains an integer , the number of people in the queue.
Each of the next lines contains an integer, the height of a person, in nanometers (equal to meters). These heights correspond to the people in the queue.
Output Format
Output a single line containing a number , the total number of pairs of people who can see each other.
7
2
4
1
2
2
5
1
10
Hint
Constraints
For all test points, each person’s height , and .
Translated by ChatGPT 5
京公网安备 11011102002149号