#K36. Count Taller Trees
Count Taller Trees
Count Taller Trees
You are given a list of integers representing the heights of trees and an integer limit. Your task is to count how many trees have a height strictly greater than the limit.
Formally, given an array of tree heights H and a limit L, find the number of indices i such that
[ H[i] > L ]
for all valid indices i.
Input Format: The first line contains an integer n representing the number of trees. The second line contains n space-separated integers denoting the heights of the trees. The third line contains an integer limit.
Output Format: Output a single integer which is the count of trees with height greater than limit.
inputFormat
The input is given in standard input (stdin) and consists of three lines:
- The first line contains a single integer
n
, the number of trees. - The second line contains
n
space-separated integers representing the heights of the trees. Ifn
is 0, this line will be empty. - The third line contains a single integer
limit
— the height threshold.
outputFormat
Output a single integer: the number of trees with a height greater than limit
.
7
3 5 6 7 8 2 1
5
3