#K6696. Counting Taller Students
Counting Taller Students
Counting Taller Students
Given a sequence of n student heights, your task is to count the number of students who are taller than the student immediately in front of them. Formally, if the height list is \(A_1, A_2, \dots, A_n\), for each \(i\) where \(2 \leq i \leq n\) check if \(A_i > A_{i-1}\). If the condition holds, increment the counter.
Example: For the input list [140, 150, 145, 160, 155], students at positions 2 and 4 are taller than the student right in front of them (since 150 > 140 and 160 > 145). Therefore, the answer is 2.
inputFormat
The first line of input contains a single integer \(n\) \((1 \leq n \leq 10^5)\) representing the number of students. The second line contains \(n\) space-separated integers representing the heights of the students in line.
For example:
5 140 150 145 160 155
outputFormat
Output a single integer which is the count of students that are taller than the student immediately in front of them.
For the sample above, the output is:
2## sample
5
140 150 145 160 155
2
</p>