Problem C
Dominating Duos
A group of people are standing in a line. Each person has a distinct height. You would like to count the number of unordered pairs of people in the line such that they are taller than everyone in between them in the line.
More formally, let
Input
The first line of input contains an integer
Each of the next
Output
Output a single integer, which is the number of pairs of people who are taller than everyone between them.
Sample Input 1 | Sample Output 1 |
---|---|
3 2 1 3 |
3 |
Sample Input 2 | Sample Output 2 |
---|---|
6 1 3 2 6 4 5 |
7 |